blob: 6217c0311e37120fc495dbcc7faa4441b7d31605 [file] [log] [blame]
Yanbiao Lia8a7d272015-07-20 17:28:45 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright 2015, Regents of the University of California.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6 * file except in compliance with the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software distributed under
11 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 * KIND, either express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16#ifndef INTEGRATION_TESTS_INSTALL_HELPERS_INFOEDIT_INFOEDIT_HPP
17#define INTEGRATION_TESTS_INSTALL_HELPERS_INFOEDIT_INFOEDIT_HPP
18
19#include <fstream>
20#include <iostream>
21#include <boost/property_tree/ptree.hpp>
22#include <boost/property_tree/info_parser.hpp>
23
24namespace infoedit {
25
26class InfoEditor
27{
28public:
29 class Error : public std::runtime_error
30 {
31 public:
32 Error(const std::string& what)
33 : std::runtime_error(what)
34 {
35 }
36 };
37
38public:
39 void
40 load(const std::string& fileName);
41
42 InfoEditor&
43 modify(const std::string& section, const std::string& value);
44
45 InfoEditor&
46 remove(const std::string& section);
47
48 InfoEditor&
49 insert(const std::string& section, std::istream& stream);
50
51 void
52 save(const std::string& fileName);
53
54private:
55 boost::property_tree::ptree m_info;
56};
57
58} // namespace infoedit
59
60#endif // INTEGRATION_TESTS_INSTALL_HELPERS_INFOEDIT_INFOEDIT_HPP