/usr/include/Poco/Util/JSONConfiguration.h is in libpoco-dev 1.8.0.1-1ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | //
// JSONConfiguration.h
//
// Library: Util
// Package: Util
// Module: JSONConfiguration
//
// Definition of the JSONConfiguration class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Util_JSONConfiguration_INCLUDED
#define Util_JSONConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#ifndef POCO_UTIL_NO_JSONCONFIGURATION
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/JSON/Object.h"
#include <istream>
namespace Poco {
namespace Util {
class Util_API JSONConfiguration : public AbstractConfiguration
/// This configuration class extracts configuration properties
/// from a JSON object. An XPath-like syntax for property
/// names is supported to allow full access to the JSON object.
///
/// Given the following JSON object as an example:
/// {
/// "config" : {
/// "prop1" : "value1",
/// "prop2" : 10,
/// "prop3" : [
/// "element1",
/// "element2"
/// ],
/// "prop4" : {
/// "prop5" : false,
/// "prop6" : null
/// }
/// }
/// }
/// The following property names would be valid and would
/// yield the shown values:
///
/// config.prop1 --> "value1"
/// config.prop3[1] --> "element2"
/// config.prop4.prop5 --> false
{
public:
JSONConfiguration();
/// Creates an empty configuration
JSONConfiguration(const std::string& path);
/// Creates a configuration and loads the JSON structure from the given file
JSONConfiguration(std::istream& istr);
/// Creates a configuration and loads the JSON structure from the given stream
JSONConfiguration(const JSON::Object::Ptr& object);
/// Creates a configuration from the given JSON object
virtual ~JSONConfiguration();
/// Destructor
void load(const std::string& path);
/// Loads the configuration from the given file
void load(std::istream& istr);
/// Loads the configuration from the given stream
void loadEmpty(const std::string& root);
/// Loads an empty object containing only a root object with the given name.
void save(std::ostream& ostr, unsigned int indent = 2) const;
/// Saves the configuration to the given stream
virtual void setInt(const std::string& key, int value);
virtual void setBool(const std::string& key, bool value);
virtual void setDouble(const std::string& key, double value);
virtual void setString(const std::string& key, const std::string& value);
virtual void removeRaw(const std::string& key);
protected:
bool getRaw(const std::string & key, std::string & value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
private:
JSON::Object::Ptr findStart(const std::string& key, std::string& lastPart);
void getIndexes(std::string& name, std::vector<int>& indexes);
void setValue(const std::string& key, const Poco::DynamicAny& value);
JSON::Object::Ptr _object;
};
} } // namespace Poco::Util
#endif // POCO_UTIL_NO_JSONCONFIGURATION
#endif // Util_JSONConfiguration_INCLUDED
|