summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/IdentityUtil.cpp
blob: 0a3fbd063ee5d9174554d0bdd4c52d0450c4fe79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#include <Ice/IdentityUtil.h>

using namespace std;
using namespace Ice;
using namespace IceInternal;

ostream&
Ice::operator<<(ostream& out, const Identity& ident)
{
    return out << identityToString(ident);
}

Identity
Ice::stringToIdentity(const string& s)
{
    Identity ident;
    string::size_type pos = s.find_first_of("/");
    if(pos != string::npos)
    {
	ident.category = s.substr(0, pos);
	ident.name = s.substr(pos + 1);
    }
    else
    {
	ident.name = s;
    }
    return ident;
}

string
Ice::identityToString(const Identity& ident)
{
    if(ident.category.empty())
    {
	return ident.name;
    }
    else
    {
	return ident.category + '/' + ident.name;
    }
}