summaryrefslogtreecommitdiffabout
path: root/lib/discovery.cc
authorMichael Krelin <hacker@klever.net>2008-02-19 23:48:32 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-19 23:48:32 (UTC)
commitdaf2d4bcb4a31df6b46d3da7a33ee3f98d85e464 (patch) (unidiff)
tree7d929285bc296777c63d4f482c7bb07f8541bce2 /lib/discovery.cc
parent42e4fb613d190508b3e8b8993d233044eeea4d20 (diff)
downloadlibopkele-daf2d4bcb4a31df6b46d3da7a33ee3f98d85e464.zip
libopkele-daf2d4bcb4a31df6b46d3da7a33ee3f98d85e464.tar.gz
libopkele-daf2d4bcb4a31df6b46d3da7a33ee3f98d85e464.tar.bz2
added an identifier normalization utility function
* moved iname leader characters and whitespace characters strings to opkele::data namespace * added opkele::util::normalize_identifier() function Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib/discovery.cc') (more/less context) (show whitespace changes)
-rw-r--r--lib/discovery.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index b7f2db6..5913ad4 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -8,2 +8,3 @@
8#include <opkele/tidy.h> 8#include <opkele/tidy.h>
9#include <opkele/data.h>
9#include <opkele/debug.h> 10#include <opkele/debug.h>
@@ -23,4 +24,2 @@ namespace opkele {
23 24
24 static const char *whitespace = " \t\r\n";
25 static const char *i_leaders = "=@+$!(";
26 static const size_t max_html = 16384; 25 static const size_t max_html = 16384;
@@ -130,6 +129,6 @@ namespace opkele {
130 idiscovery_t idis; 129 idiscovery_t idis;
131 string::size_type fsc = identity.find_first_not_of(whitespace); 130 string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars);
132 if(fsc==string::npos) 131 if(fsc==string::npos)
133 throw bad_input(OPKELE_CP_ "whitespace-only identity"); 132 throw bad_input(OPKELE_CP_ "whitespace-only identity");
134 string::size_type lsc = identity.find_last_not_of(whitespace); 133 string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars);
135 assert(lsc!=string::npos); 134 assert(lsc!=string::npos);
@@ -141,3 +140,3 @@ namespace opkele {
141 idis.clear(); 140 idis.clear();
142 if(strchr(i_leaders,id[0])) { 141 if(strchr(data::_iname_leaders,id[0])) {
143 /* TODO: further normalize xri identity? Like folding case 142 /* TODO: further normalize xri identity? Like folding case
@@ -497,3 +496,3 @@ namespace opkele {
497 href.assign(ns); 496 href.assign(ns);
498 string::size_type lns=href.find_last_not_of(whitespace); 497 string::size_type lns=href.find_last_not_of(data::_whitespace_chars);
499 href.erase(lns+1); 498 href.erase(lns+1);
@@ -501,5 +500,5 @@ namespace opkele {
501 } 500 }
502 for(string::size_type ns=rels.find_first_not_of(whitespace); 501 for(string::size_type ns=rels.find_first_not_of(data::_whitespace_chars);
503 ns!=string::npos; ns=rels.find_first_not_of(whitespace,ns)) { 502 ns!=string::npos; ns=rels.find_first_not_of(data::_whitespace_chars,ns)) {
504 string::size_type s = rels.find_first_of(whitespace,ns); 503 string::size_type s = rels.find_first_of(data::_whitespace_chars,ns);
505 string rel; 504 string rel;