summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aria2api.cc17
-rw-r--r--src/includes/aria2/aria2.h6
2 files changed, 21 insertions, 2 deletions
diff --git a/src/aria2api.cc b/src/aria2api.cc
index f42ca5ed..3c2be5ac 100644
--- a/src/aria2api.cc
+++ b/src/aria2api.cc
@@ -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
diff --git a/src/includes/aria2/aria2.h b/src/includes/aria2/aria2.h
index 63b952fd..d0a0c30f 100644
--- a/src/includes/aria2/aria2.h
+++ b/src/includes/aria2/aria2.h
@@ -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