Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
tiny_ini.h
Go to the documentation of this file.
1
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
2
// All rights reserved.
3
//
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are met:
6
// * Redistributions of source code must retain the above copyright
7
// notice, this list of conditions and the following disclaimer.
8
// * Redistributions in binary form must reproduce the above copyright
9
// notice, this list of conditions and the following disclaimer in the
10
// documentation and/or other materials provided with the distribution.
11
// * Neither the name of the Andrey N. Sabelnikov nor the
12
// names of its contributors may be used to endorse or promote products
13
// derived from this software without specific prior written permission.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
19
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
//
26
27
28
#ifndef _TINY_INI_H_
29
#define _TINY_INI_H_
30
31
#include <boost/regex.hpp>
32
#include <boost/lexical_cast.hpp>
33
#include "
string_tools.h
"
34
35
namespace
epee
36
{
37
namespace
tiny_ini
38
{
39
40
inline
41
bool
get_param_value
(
const
std::string& param_name,
const
std::string& ini_entry, std::string&
res
)
42
{
43
std::string expr_str = std::string() +
"^("
+ param_name +
") *=(.*?)$"
;
44
const
boost::regex match_ini_entry( expr_str, boost::regex::icase | boost::regex::normal);
45
boost::smatch result;
46
if
(!boost::regex_search(ini_entry, result, match_ini_entry, boost::match_default))
47
return
false
;
48
res
= result[2];
49
string_tools::trim
(
res
);
50
return
true
;
51
}
52
inline
53
std::string
get_param_value
(
const
std::string& param_name,
const
std::string& ini_entry)
54
{
55
std::string buff;
56
get_param_value
(param_name, ini_entry, buff);
57
return
buff;
58
}
59
60
template
<
class
T>
61
bool
get_param_value_as_t
(
const
std::string& param_name,
const
std::string& ini_entry,
T
&
res
)
62
{
63
std::string str_res =
get_param_value
(param_name, ini_entry);
64
65
string_tools::trim
(str_res);
66
if
(!str_res.size())
67
return
false
;
68
69
return
string_tools::get_xtype_from_string
(
res
, str_res);
70
}
71
72
}
73
}
74
75
#endif
//_TINY_INI_H_
res
const char * res
Definition
hmac_keccak.cpp:41
epee::string_tools::get_xtype_from_string
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
Definition
string_tools.h:125
epee::string_tools::trim
std::string & trim(std::string &str)
Definition
string_tools.h:288
epee::tiny_ini
Definition
tiny_ini.h:38
epee::tiny_ini::get_param_value_as_t
bool get_param_value_as_t(const std::string ¶m_name, const std::string &ini_entry, T &res)
Definition
tiny_ini.h:61
epee::tiny_ini::get_param_value
bool get_param_value(const std::string ¶m_name, const std::string &ini_entry, std::string &res)
Definition
tiny_ini.h:41
epee
Definition
ado_db_helper.h:67
string_tools.h
T
#define T(x)
contrib
epee
include
tiny_ini.h
Generated on
for Electroneum by
1.17.0