author | Michael Krelin <hacker@klever.net> | 2008-03-03 14:58:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-03-03 14:58:09 (UTC) |
commit | 0182b9dee269f1a8f3fc0794bfdf4a143fa1b5be (patch) (unidiff) | |
tree | 0e435d48a9d2b94ff309c8fea2d416e0e14d8b2a | |
parent | 5fd5ecad8c2bd1e8846c11fa9b281f0f4ab8a4a7 (diff) | |
download | libopkele-0182b9dee269f1a8f3fc0794bfdf4a143fa1b5be.zip libopkele-0182b9dee269f1a8f3fc0794bfdf4a143fa1b5be.tar.gz libopkele-0182b9dee269f1a8f3fc0794bfdf4a143fa1b5be.tar.bz2 |
added append_to() to basic_openid_message
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/types.h | 1 | ||||
-rw-r--r-- | lib/openid_message.cc | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h index af7fb1a..ffb9afb 100644 --- a/include/opkele/types.h +++ b/include/opkele/types.h | |||
@@ -120,24 +120,25 @@ namespace opkele { | |||
120 | 120 | ||
121 | class basic_openid_message { | 121 | class basic_openid_message { |
122 | public: | 122 | public: |
123 | typedef list<string> fields_t; | 123 | typedef list<string> fields_t; |
124 | typedef util::forward_iterator_proxy< | 124 | typedef util::forward_iterator_proxy< |
125 | string,const string&,const string* | 125 | string,const string&,const string* |
126 | > fields_iterator; | 126 | > fields_iterator; |
127 | 127 | ||
128 | basic_openid_message() { } | 128 | basic_openid_message() { } |
129 | virtual ~basic_openid_message() { } | 129 | virtual ~basic_openid_message() { } |
130 | basic_openid_message(const basic_openid_message& x); | 130 | basic_openid_message(const basic_openid_message& x); |
131 | void copy_to(basic_openid_message& x) const; | 131 | void copy_to(basic_openid_message& x) const; |
132 | void append_to(basic_openid_message& x) const; | ||
132 | 133 | ||
133 | virtual bool has_field(const string& n) const = 0; | 134 | virtual bool has_field(const string& n) const = 0; |
134 | virtual const string& get_field(const string& n) const = 0; | 135 | virtual const string& get_field(const string& n) const = 0; |
135 | 136 | ||
136 | virtual bool has_ns(const string& uri) const; | 137 | virtual bool has_ns(const string& uri) const; |
137 | virtual string get_ns(const string& uri) const; | 138 | virtual string get_ns(const string& uri) const; |
138 | 139 | ||
139 | virtual fields_iterator fields_begin() const = 0; | 140 | virtual fields_iterator fields_begin() const = 0; |
140 | virtual fields_iterator fields_end() const = 0; | 141 | virtual fields_iterator fields_end() const = 0; |
141 | 142 | ||
142 | virtual string append_query(const string& url,const char *pfx="openid.") const; | 143 | virtual string append_query(const string& url,const char *pfx="openid.") const; |
143 | virtual string query_string(const char *pfx="openid.") const; | 144 | virtual string query_string(const char *pfx="openid.") const; |
diff --git a/lib/openid_message.cc b/lib/openid_message.cc index 4b9179b..e244f43 100644 --- a/lib/openid_message.cc +++ b/lib/openid_message.cc | |||
@@ -7,36 +7,39 @@ | |||
7 | #include "config.h" | 7 | #include "config.h" |
8 | 8 | ||
9 | namespace opkele { | 9 | namespace opkele { |
10 | using std::input_iterator_tag; | 10 | using std::input_iterator_tag; |
11 | using std::unary_function; | 11 | using std::unary_function; |
12 | 12 | ||
13 | struct __om_copier : public unary_function<const string&,void> { | 13 | struct __om_copier : public unary_function<const string&,void> { |
14 | public: | 14 | public: |
15 | const basic_openid_message& from; | 15 | const basic_openid_message& from; |
16 | basic_openid_message& to; | 16 | basic_openid_message& to; |
17 | 17 | ||
18 | __om_copier(basic_openid_message& t,const basic_openid_message& f) | 18 | __om_copier(basic_openid_message& t,const basic_openid_message& f) |
19 | : from(f), to(t) { | 19 | : from(f), to(t) { } |
20 | to.reset_fields(); | ||
21 | } | ||
22 | 20 | ||
23 | result_type operator()(argument_type f) { | 21 | result_type operator()(argument_type f) { |
24 | to.set_field(f,from.get_field(f)); } | 22 | to.set_field(f,from.get_field(f)); } |
25 | }; | 23 | }; |
26 | 24 | ||
27 | basic_openid_message::basic_openid_message(const basic_openid_message& x) { | 25 | basic_openid_message::basic_openid_message(const basic_openid_message& x) { |
28 | x.copy_to(*this); | 26 | x.copy_to(*this); |
29 | } | 27 | } |
30 | void basic_openid_message::copy_to(basic_openid_message& x) const { | 28 | void basic_openid_message::copy_to(basic_openid_message& x) const { |
29 | x.reset_fields(); | ||
30 | for_each(fields_begin(),fields_end(), | ||
31 | __om_copier(x,*this) ); | ||
32 | } | ||
33 | void basic_openid_message::append_to(basic_openid_message& x) const { | ||
31 | for_each(fields_begin(),fields_end(), | 34 | for_each(fields_begin(),fields_end(), |
32 | __om_copier(x,*this) ); | 35 | __om_copier(x,*this) ); |
33 | } | 36 | } |
34 | 37 | ||
35 | struct __om_ns_finder : public unary_function<const string&,bool> { | 38 | struct __om_ns_finder : public unary_function<const string&,bool> { |
36 | public: | 39 | public: |
37 | const basic_openid_message& om; | 40 | const basic_openid_message& om; |
38 | const string& uri; | 41 | const string& uri; |
39 | 42 | ||
40 | __om_ns_finder(const basic_openid_message& m, | 43 | __om_ns_finder(const basic_openid_message& m, |
41 | const string& u) : om(m), uri(u) { } | 44 | const string& u) : om(m), uri(u) { } |
42 | 45 | ||