X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=ref.cc;fp=ref.cc;h=84b631c54b30f088d2282874144c381c61613fb0;hb=4b89157cdec2da9a016a7ea0f511a0f3ff43f6dc;hp=ce16cb8914fa649dd40fce3dc0f18a363cee0ac8;hpb=e392d943a0bca2f12186321ae1658b739a5a5dd4;p=cumulus.git diff --git a/ref.cc b/ref.cc index ce16cb8..84b631c 100644 --- a/ref.cc +++ b/ref.cc @@ -71,8 +71,22 @@ string ObjectReference::to_string() const /* Parse a string object reference and return a pointer to a new * ObjectReference. The caller is responsible for freeing the object. NULL is * returned if there is an error in the syntax. */ -ObjectReference *ObjectReference::parse(const std::string& s) +ObjectReference *ObjectReference::parse(const std::string& str) { - // TODO: Implement - return NULL; + const char *s = str.c_str(); + const char *t; + + // Segment + t = strchr(s, '/'); + if (t == NULL) + return NULL; + string segment(s, t - s); + + // Object sequence number + s = t + 1; + string object(s); + + // TODO: Checksums, ranges. + + return new ObjectReference(segment, object); }