summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/IdentityUtil.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-08-27 18:46:05 +0000
committerMark Spruiell <mes@zeroc.com>2002-08-27 18:46:05 +0000
commitfcd354c185711a2936a053fdd22bf7deb5691705 (patch)
tree8ee9c346cfc28f17fad8079f56d253f7ed96c5d9 /cpp/src/Ice/IdentityUtil.cpp
parentinitial check-in (diff)
downloadice-fcd354c185711a2936a053fdd22bf7deb5691705.tar.bz2
ice-fcd354c185711a2936a053fdd22bf7deb5691705.tar.xz
ice-fcd354c185711a2936a053fdd22bf7deb5691705.zip
adding escapes for references, identity
Diffstat (limited to 'cpp/src/Ice/IdentityUtil.cpp')
-rw-r--r--cpp/src/Ice/IdentityUtil.cpp42
1 files changed, 35 insertions, 7 deletions
diff --git a/cpp/src/Ice/IdentityUtil.cpp b/cpp/src/Ice/IdentityUtil.cpp
index 0a3fbd063ee..a8e2b968237 100644
--- a/cpp/src/Ice/IdentityUtil.cpp
+++ b/cpp/src/Ice/IdentityUtil.cpp
@@ -9,6 +9,8 @@
// **********************************************************************
#include <Ice/IdentityUtil.h>
+#include <Ice/StringUtil.h>
+#include <Ice/LocalException.h>
using namespace std;
using namespace Ice;
@@ -24,16 +26,42 @@ Identity
Ice::stringToIdentity(const string& s)
{
Identity ident;
- string::size_type pos = s.find_first_of("/");
- if(pos != string::npos)
+
+ //
+ // Find unescaped separator
+ //
+ string::size_type slash = 0;
+ while((slash = s.find('/', slash)) != string::npos)
{
- ident.category = s.substr(0, pos);
- ident.name = s.substr(pos + 1);
+ if(slash == 0 || s[slash - 1] != '\\')
+ {
+ break;
+ }
+ slash++;
+ }
+
+ if(slash == string::npos)
+ {
+ if(!decodeString(s, 0, 0, ident.name))
+ {
+ throw SystemException(__FILE__, __LINE__);
+ }
}
else
{
- ident.name = s;
+ if(!decodeString(s, 0, slash, ident.category))
+ {
+ throw SystemException(__FILE__, __LINE__);
+ }
+ if(slash + 1 < s.size())
+ {
+ if(!decodeString(s, slash + 1, 0, ident.name))
+ {
+ throw SystemException(__FILE__, __LINE__);
+ }
+ }
}
+
return ident;
}
@@ -42,10 +70,10 @@ Ice::identityToString(const Identity& ident)
{
if(ident.category.empty())
{
- return ident.name;
+ return encodeString(ident.name, "/");
}
else
{
- return ident.category + '/' + ident.name;
+ return encodeString(ident.category, "/") + '/' + encodeString(ident.name, "/");
}
}