A few minor adjustments to the ObjectReference interface.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Fri, 11 May 2007 17:32:00 +0000 (10:32 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Fri, 11 May 2007 17:32:00 +0000 (10:32 -0700)
ref.cc
ref.h

diff --git a/ref.cc b/ref.cc
index e996c7d..ff710d2 100644 (file)
--- a/ref.cc
+++ b/ref.cc
@@ -40,6 +40,14 @@ ObjectReference::ObjectReference(const std::string& segment, int sequence)
     clear_range();
 }
 
+ObjectReference::ObjectReference(const std::string& segment,
+                                 const std::string& sequence)
+    : segment(segment), object(sequence)
+{
+    clear_checksum();
+    clear_range();
+}
+
 string ObjectReference::to_string() const
 {
     string result = segment + "/" + object;
@@ -55,3 +63,12 @@ string ObjectReference::to_string() const
 
     return result;
 }
+
+/* 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)
+{
+    // TODO: Implement
+    return NULL;
+}
diff --git a/ref.h b/ref.h
index 496fdec..13eba94 100644 (file)
--- a/ref.h
+++ b/ref.h
@@ -65,11 +65,14 @@ std::string generate_uuid();
 class ObjectReference {
 public:
     ObjectReference(const std::string& segment, int sequence);
+    ObjectReference(const std::string& segment, const std::string& sequence);
 
     std::string to_string() const;
+    static ObjectReference *parse(const std::string& s);
 
     std::string get_segment() const { return segment; }
-    void set_segment(const std::string& segment) { this->segment = segment; }
+    std::string get_sequence() const { return object; }
+    std::string get_basename() const { return segment + "/" + object; }
 
     bool has_checksum() const { return checksum_valid; }
     std::string get_checksum() const { return checksum; }