2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef PLUGIN_CONFIG_HPP_INCLUDED
18 #define PLUGIN_CONFIG_HPP_INCLUDED
21 * @file pluginConfig.hpp
30 // comment this to enter release mode (i.e. diable couts)
38 #include "pluginConfigTypes.h"
41 * @brief Namespace for all content related to plugin.
46 * Internal backing storage for configuration.
54 * @brief General-purpose, class for loading and reading configuration from
55 * simple plaintext files.
73 * @brief Loads configuration to memory and/or gets raw data from configuration.
75 * @param section will return value attached to a key from this section
76 * @param key will return value attached to this key
79 std::string _getRaw(const std::string §ion, const std::string &key);
82 * @brief Loads configuration to memory and/or gets raw data from configuration.
84 * @param section will return value attached to a key from this section
85 * @param key will return value attached to this key
86 * @return :string pointer
88 const std::string *_getRawPtr(const std::string §ion, const std::string &key);
92 * @brief Loads the configuration from a given file into memory.
94 * @param filepath path to the configuration file that will be loaded
95 * @param type expected type of configuration file, this value determines
96 * how the file is parsed
97 * @return int return true if successful, false otherwise
99 bool load(const std::string &filepath, PluginConfigType type);
102 * @brief Unloads the configuration from the memory.
104 * The configuration is automatically unloaded when the Config object is
105 * destoyed, so this method does not have to be executed unless you need
106 * to extremely lower memory usage and few bytes matter.
113 * @brief Checks wheteher config file has been loaded.
115 * @return bool return true if successful, false otherwise
121 * @brief From loaded configuration, gets string value attached to given key.
125 * @return :string value attached to the key from the section
127 std::string getString(const std::string §ion, const std::string &key);
130 * @brief From loaded configuration, gets string pointer attached to given key.
134 * @return :string pointer attached to the key from the section
136 const std::string *getStringPtr(const std::string §ion, const std::string &key);
139 * @brief From loaded configuration, gets integer value attached to given key.
141 * @param section will return value attached to a key from this section
142 * @param key will return value attached to this key
145 int getInt(const std::string §ion, const std::string &key);
148 * @brief From _loaded configuration, gets double value attached to given key.
150 * @param section will return value attached to a key from this section
151 * @param key will return value attached to this key
154 double getDouble(const std::string §ion, const std::string &key);
158 internal::ConfigData *_configuration;
161 #endif /* PLUGIN_CONFIG_HPP_INCLUDED */