1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014 Adam Crume <adamcrume@gmail.com>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef _INCLUDED_RBD_REPLAY_RBD_LOC_HPP
16 #define _INCLUDED_RBD_REPLAY_RBD_LOC_HPP
20 namespace rbd_replay {
23 Stores a pool, image name, and snap name triple.
24 rbd_locs can be converted to/from strings with the format pool/image\@snap.
25 The slash and at signs can be omitted if the pool and snap are empty, respectively.
26 Backslashes can be used to escape slashes and at signs in names.
29 |Pool | Image | Snap | String |
30 |------|-------|------|--------------------|
31 |rbd | vm | 1 | rbd/vm\@1 |
32 |rbd | vm | | rbd/vm |
35 |rbd | | 1 | rbd/\@1 |
36 |rbd\@x| vm/y | 1 | rbd\\\@x/vm\\/y\@1 |
38 (The empty string should obviously be avoided as the image name.)
40 Note that the non-canonical forms /vm\@1 and rbd/vm\@ can also be parsed,
41 although they will be formatted as vm\@1 and rbd/vm.
45 Constructs an rbd_loc with the empty string for the pool, image, and snap.
50 Constructs an rbd_loc with the given pool, image, and snap.
52 rbd_loc(std::string pool, std::string image, std::string snap);
55 Parses an rbd_loc from the given string.
56 If parsing fails, the contents are unmodified.
57 @retval true if parsing succeeded
59 bool parse(std::string name_string);
62 Returns the string representation of the locator.
64 std::string str() const;
67 Compares the locators lexicographically by pool, then image, then snap.
69 int compare(const rbd_loc& rhs) const;
72 Returns true if the locators have identical pool, image, and snap.
74 bool operator==(const rbd_loc& rhs) const;
77 Compares the locators lexicographically by pool, then image, then snap.
79 bool operator<(const rbd_loc& rhs) const;