X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=ref.h;h=d1a0e0c66a7a9765041c32dc1818266437bebfa3;hb=908cfc1af3e761d3243d31a68420fb8994840721;hp=e499e6e2669a6f48c3a872725c3bc1ce74e705e8;hpb=d3c10b747ecec0acc14863fc12db9661c3f88128;p=cumulus.git diff --git a/ref.h b/ref.h index e499e6e..d1a0e0c 100644 --- a/ref.h +++ b/ref.h @@ -1,7 +1,24 @@ -/* LBS: An LFS-inspired filesystem backup system - * Copyright (C) 2007 Michael Vrable +/* Cumulus: Smart Filesystem Backup to Dumb Servers * - * Backups are structured as a collection of objects, which may refer to other + * Copyright (C) 2007-2008 The Regents of the University of California + * Written by Michael Vrable + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* Backups are structured as a collection of objects, which may refer to other * objects. Object references are used to name other objects or parts of them. * This file defines the class for representing object references and the * textual representation of these references. */ @@ -39,7 +56,8 @@ * range specifier is given, then by default the entire object is used. * ::= "+" * Both and are decimal values. If included, the range is - * enclosed in brackets. + * enclosed in brackets. As an abbreviation, if is 0 then the range + * can be given as just (no "+" needed). * * When both a checksum and a range are included, note that the checksum is * taken over the entire original object, before the range is taken into @@ -79,6 +97,7 @@ public: std::string get_segment() const { return segment; } std::string get_sequence() const { return object; } std::string get_basename() const { return segment + "/" + object; } + ObjectReference base() const { return ObjectReference(segment, object); } bool has_checksum() const { return checksum_valid; } std::string get_checksum() const { return checksum; } @@ -95,6 +114,12 @@ public: bool merge(ObjectReference ref); + // Maybe provide non-string implementations? + bool operator==(const ObjectReference &x) const + { return to_string() == x.to_string(); } + bool operator<(const ObjectReference &x) const + { return to_string() < x.to_string(); } + private: RefType type; std::string segment, object, checksum;