Loading...
Searching...
No Matches
IniParser.h
/*
* Copyright (C) 2013 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com>
*/
#ifndef UNITY_UTIL_INIPARSER_H
#define UNITY_UTIL_INIPARSER_H
#include <unity/SymbolExport.h>
#include <unity/util/DefinesPtrs.h>
#include <string>
#include <vector>
namespace unity
{
namespace util
{
namespace internal
{
struct IniParserPrivate;
}
class UNITY_API IniParser final {
public:
IniParser(const char* filename);
~IniParser() noexcept;
UNITY_DEFINES_PTRS(IniParser);
IniParser(const IniParser& ip) = delete;
IniParser() = delete;
//{@
bool has_group(const std::string& group) const noexcept;
bool has_key(const std::string& group, const std::string& key) const;
std::string get_string(const std::string& group, const std::string& key) const;
std::string get_locale_string(const std::string& group,
const std::string& key,
const std::string& locale = std::string()) const;
bool get_boolean(const std::string& group, const std::string& key) const;
int get_int(const std::string& group, const std::string& key) const;
double get_double(const std::string& group, const std::string& key) const;
std::vector<std::string> get_string_array(const std::string& group, const std::string& key) const;
std::vector<std::string> get_locale_string_array(const std::string& group,
const std::string& key,
const std::string& locale = std::string()) const;
std::vector<bool> get_boolean_array(const std::string& group, const std::string& key) const;
std::vector<int> get_int_array(const std::string& group, const std::string& key) const;
std::vector<double> get_double_array(const std::string& group, const std::string& key) const;
std::string get_start_group() const;
std::vector<std::string> get_groups() const;
std::vector<std::string> get_keys(const std::string& group) const;
bool remove_group(const std::string& group);
bool remove_key(const std::string& group, const std::string& key);
void set_string(const std::string& group, const std::string& key, const std::string& value);
void set_locale_string(const std::string& group,
const std::string& key,
const std::string& value,
const std::string& locale = std::string());
void set_boolean(const std::string& group, const std::string& key, bool value);
void set_int(const std::string& group, const std::string& key, int value);
void set_double(const std::string& group, const std::string& key, double value);
void set_string_array(const std::string& group, const std::string& key, const std::vector<std::string>& value);
void set_locale_string_array(const std::string& group,
const std::string& key,
const std::vector<std::string>& value,
const std::string& locale = std::string());
void set_boolean_array(const std::string& group, const std::string& key, const std::vector<bool>& value);
void set_int_array(const std::string& group, const std::string& key, const std::vector<int>& value);
void set_double_array(const std::string& group, const std::string& key, const std::vector<double>& value);
void sync();
private:
internal::IniParserPrivate* p;
};
} // namespace util
} // namespace unity
#endif
DefinesPtrs.h
UNITY_DEFINES_PTRS
#define UNITY_DEFINES_PTRS(classname)
Macro to add smart pointer definitions to a class.
Definition DefinesPtrs.h:52
unity::util::IniParser::IniParser
IniParser(const char *filename)
Definition IniParser.cpp:71
unity
Top-level namespace for all things Unity-related.
Definition Version.h:38