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 #include "ImageNameMap.hpp"
19 using namespace rbd_replay;
22 bool ImageNameMap::parse_mapping(string mapping_string, Mapping *mapping) const {
25 for (size_t i = 0, n = mapping_string.length(); i < n; i++) {
26 char c = mapping_string[i];
29 if (i != n - 1 && mapping_string[i + 1] == '=') {
31 fields[field].push_back('=');
33 fields[field].push_back('\\');
43 fields[field].push_back(c);
49 if (!mapping->first.parse(fields[0])) {
52 if (!mapping->second.parse(fields[1])) {
58 void ImageNameMap::add_mapping(const Mapping& mapping) {
59 m_map.insert(mapping);
62 rbd_loc ImageNameMap::map(const rbd_loc& name) const {
63 std::map<rbd_loc, rbd_loc>::const_iterator p(m_map.find(name));
64 if (p == m_map.end()) {