From c26f44fe8cd3eeec0d9d849cb2e639d484de5887 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Fri, 11 May 2007 10:32:00 -0700 Subject: [PATCH] A few minor adjustments to the ObjectReference interface. --- ref.cc | 17 +++++++++++++++++ ref.h | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ref.cc b/ref.cc index e996c7d..ff710d2 100644 --- 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 --- 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; } -- 2.20.1