Rename gidToString as gidToHex, add hexToGid and isNull

This commit is contained in:
Tatsuhiro Tsujikawa 2013-04-30 22:51:05 +09:00
parent 1df4adefb5
commit 8f659f49ec
2 changed files with 21 additions and 2 deletions

View File

@ -109,11 +109,26 @@ int run(Session* session, RUN_MODE mode)
return e->run(mode == RUN_ONCE);
}
std::string gidToString(const A2Gid& gid)
std::string gidToHex(const A2Gid& gid)
{
return GroupId::toHex(gid);
}
A2Gid hexToGid(const std::string& hex)
{
A2Gid gid;
if(GroupId::toNumericId(gid, hex.c_str()) == 0) {
return gid;
} else {
return 0;
}
}
bool isNull(const A2Gid& gid)
{
return gid == 0;
}
namespace {
template<typename InputIterator, typename Pred>
void apiGatherOption

View File

@ -107,7 +107,11 @@ enum RUN_MODE {
int run(Session* session, RUN_MODE mode);
// Returns textual representation of the |gid|.
std::string gidToString(const A2Gid& gid);
std::string gidToHex(const A2Gid& gid);
// Returns GID converted from the textual representation |hex|.
A2Gid hexToGid(const std::string& hex);
// Returns true if the |gid| is invalid.
bool isNull(const A2Gid& gid);
// This method adds new HTTP(S)/FTP/BitTorrent Magnet URI. On
// successful return, the |gid| includes the GID of newly added