advgetopt 2.0.49
Parse complex command line arguments and configuration files in C++.
option_info.cpp
Go to the documentation of this file.
1// Copyright (c) 2006-2025 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/advgetopt
4// contact@m2osw.com
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
17// with this program; if not, write to the Free Software Foundation, Inc.,
18// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
28// self
29//
31
32#include "advgetopt/exception.h"
35
36
37// cppthread
38//
39#include <cppthread/guard.h>
40#include <cppthread/log.h>
41#include <cppthread/mutex.h>
42
43
44// snapdev
45//
46#include <snapdev/not_used.h>
47#include <snapdev/tokenize_string.h>
48
49
50// libutf8
51//
52#include <libutf8/libutf8.h>
53#include <libutf8/iterator.h>
54
55
56// last include
57//
58#include <snapdev/poison.h>
59
60
61
62namespace advgetopt
63{
64
65
66namespace
67{
68
69
84bool g_trace_sources = false;
85
86
97std::string g_configuration_filename = std::string();
98
99
100
101} // no name namespace
102
103
104
105// from utils.cpp
106//
107// (it's here because we do not want to make cppthread public in
108// out header files--we could have an advgetopt_private.h, though)
109//
110cppthread::mutex & get_global_mutex();
111
112
113
114
128short_name_t string_to_short_name(std::string const & name)
129{
130 if(!name.empty())
131 {
132 libutf8::utf8_iterator u8(name);
133 short_name_t const short_name(*u8++);
134 if(u8 == name.end())
135 {
136 return short_name;
137 }
138 }
139
140 return NO_SHORT_NAME;
141}
142
143
163{
165 {
166 return std::string();
167 }
168 return libutf8::to_u8string(short_name);
169}
170
171
225 : f_name(option_with_dashes(name))
226 , f_short_name(short_name)
227{
228 if(f_name.empty())
229 {
231 {
232 throw getopt_logic_error(
233 "option_info::option_info(): all options must at least have a long name (short name: '"
234 + libutf8::to_u8string(short_name)
235 + "'.)");
236 }
237 throw getopt_logic_error(
238 "option_info::option_info(): all options must at least have a long name.");
239 }
240
241 if(f_name == "--")
242 {
244 {
245 throw getopt_logic_error(
246 "option_info::option_info(): the default parameter \"--\" cannot include a short name ('"
247 + libutf8::to_u8string(short_name)
248 + "'.)");
249 }
250
252 }
253 else
254 {
255 if(f_name[0] == '-')
256 {
257 throw getopt_logic_error(
258 "option_info::option_info(): an option cannot start with a dash (-), \""
259 + f_name
260 + "\" is not valid.");
261 }
262
263 if(short_name == '-')
264 {
265 throw getopt_logic_error(
266 "option_info::option_info(): the short name of an option cannot be the dash (-).");
267 }
268 }
269}
270
271
287std::string const & option_info::get_name() const
288{
289 return f_name;
290}
291
292
316
317
330
331
344std::string option_info::get_basename() const
345{
346 std::string::size_type const pos(f_name.rfind("::"));
347 if(pos == std::string::npos)
348 {
349 return f_name;
350 }
351
352 return f_name.substr(pos + 2);
353}
354
355
372{
373 std::string::size_type const pos(f_name.rfind("::"));
374 if(pos == std::string::npos)
375 {
376 return std::string();
377 }
378
379 return f_name.substr(0, pos);
380}
381
382
399{
400 std::string::size_type const pos(f_name.rfind("::"));
401 if(pos == std::string::npos)
402 {
403 return string_list_t();
404 }
405
407 snapdev::tokenize_string(section_list
408 , f_name.substr(0, pos)
409 , "::"
410 , true
411 , std::string()
412 , &snapdev::string_predicate<string_list_t>);
413 return section_list;
414}
415
416
431{
433 || (f_name.size() == 2 && f_name[0] == '-' && f_name[1] == '-');
434}
435
436
451void option_info::set_environment_variable_name(std::string const & name)
452{
454}
455
456
469{
470 if(name != nullptr)
471 {
472 set_environment_variable_name(std::string(name));
473 }
474}
475
476
497
498
514 std::string & value
515 , char const * intro) const
516{
517 // make it empty by default
518 //
519 value.clear();
520
522 {
523 return false;
524 }
525
526 std::string name(f_environment_variable_name);
527 if(intro != nullptr)
528 {
529 name = intro + name;
530 }
531
532 char const * env(getenv(name.c_str()));
533 if(env == nullptr)
534 {
535 return false;
536 }
537
538 value = env;
539
540 return true;
541}
542
543
568
569
583
584
598
599
610{
611 return f_flags;
612}
613
614
626{
627 return (f_flags & flag) != 0;
628}
629
630
651
652
679
680
693{
694 if(default_value != nullptr)
695 {
696 set_default(std::string(default_value));
697 }
698}
699
700
715
716
723std::string const & option_info::get_default() const
724{
725 return f_default_value;
726}
727
728
764void option_info::set_help(std::string const & help)
765{
766 f_help = help;
767}
768
769
777void option_info::set_help(char const * help)
778{
779 if(help != nullptr)
780 {
781 set_help(std::string(help));
782 }
783}
784
785
796std::string const & option_info::get_help() const
797{
798 return f_help;
799}
800
801
840
841
868{
870
871 // make sure that all existing values validate against this
872 // new validator
873 //
874 std::size_t const size(f_value.size());
875 bool const r(validate_all_values());
876 if(size != f_value.size())
877 {
878 value_changed(0);
879 }
880 return r;
881}
882
883
895{
896 snapdev::NOT_USED(null_ptr);
897
898 f_validator.reset();
899
900 return true;
901}
902
903
926{
927 if(static_cast<size_t>(idx) >= f_value.size())
928 {
929 throw getopt_undefined( // LCOV_EXCL_LINE
930 "option_info::validates(): no value at index " // LCOV_EXCL_LINE
931 + std::to_string(idx) // LCOV_EXCL_LINE
932 + " (idx >= " // LCOV_EXCL_LINE
933 + std::to_string(f_value.size()) // LCOV_EXCL_LINE
934 + ") for --" // LCOV_EXCL_LINE
935 + f_name // LCOV_EXCL_LINE
936 + " so you can't get this value."); // LCOV_EXCL_LINE
937 }
938
939 // the value is considered valid when:
940 // * there is no validator
941 // * if the value is empty
942 // * when the value validate against the specified validator
943 //
944 if(f_validator == nullptr
945 || f_value[idx].empty()
946 || f_validator->validate(f_value[idx]))
947 {
948 return true;
949 }
950
951 cppthread::log << cppthread::log_level_t::error
952 << "input \""
953 << f_value[idx]
954 << "\" given to parameter --"
955 << f_name
956 << " is not considered valid: "
957 << f_validator->get_error()
958 << cppthread::end;
959
960 // get rid of that value since it does not validate
961 //
962 f_value.erase(f_value.begin() + idx);
963 if(f_value.empty())
964 {
966 }
967
968 return false;
969}
970
971
993
994
1004{
1005 if(destination->has_flag(GETOPT_FLAG_ALIAS))
1006 {
1007 throw getopt_invalid(
1008 "option_info::set_alias(): you can't set an alias as"
1009 " an alias of another option.");
1010 }
1011
1013}
1014
1015
1026
1027
1044{
1045 f_multiple_separators.clear();
1046 if(separators == nullptr)
1047 {
1048 return;
1049 }
1050
1051 for(; *separators != nullptr; ++separators)
1052 {
1054 }
1055}
1056
1057
1076
1077
1101
1102
1116
1117
1131
1132
1149bool option_info::has_value(std::string const & value) const
1150{
1151 auto const it(std::find(f_value.begin(), f_value.end(), value));
1152 return it != f_value.end();
1153}
1154
1155
1179 std::string const & value
1180 , string_list_t const & option_keys
1181 , option_source_t source)
1182{
1183 return set_value(
1185 ? f_value.size()
1186 : 0
1187 , value
1188 , option_keys
1189 , source);
1190}
1191
1192
1226 int idx
1227 , std::string const & value
1228 , string_list_t const & option_keys
1229 , option_source_t source)
1230{
1232 {
1233 throw getopt_logic_error(
1234 "option_info::set_value(): called with SOURCE_UNDEFINED ("
1235 + std::to_string(static_cast<int>(source))
1236 + ").");
1237 }
1238
1240 {
1241 return false;
1242 }
1243
1246 {
1247 cppthread::log << cppthread::log_level_t::error
1248 << "option \"--"
1249 << f_name
1250 << "\" can't be directly updated."
1251 << cppthread::end;
1252 return false;
1253 }
1254
1256 if(multiple)
1257 {
1258 if(static_cast<size_t>(idx) > f_value.size())
1259 {
1260 throw getopt_logic_error(
1261 "option_info::set_value(): no value at index "
1262 + std::to_string(idx)
1263 + " and it is not the last available index + 1 (idx > "
1264 + std::to_string(f_value.size())
1265 + ") so you can't set this value (try add_value() maybe?).");
1266 }
1267 }
1268 else
1269 {
1270 if(idx != 0)
1271 {
1272 throw getopt_logic_error(
1273 "option_info::set_value(): single value option \"--"
1274 + f_name
1275 + "\" does not accepts index "
1276 + std::to_string(idx)
1277 + " which is not 0.");
1278 }
1279 }
1280
1281 f_source = source;
1282 f_integer.clear();
1283 f_double.clear();
1284
1285 bool r(true);
1286 if(option_keys.empty())
1287 {
1288 if(static_cast<size_t>(idx) == f_value.size())
1289 {
1290 f_value.push_back(value);
1291 }
1292 else
1293 {
1294 if(f_value[idx] == value)
1295 {
1296 // no change, we can return as is
1297 //
1298 // note: we know that the value is valid here since the
1299 // validates() function removes invalid values from
1300 // the f_value array
1301 //
1302 return true;
1303 }
1304 f_value[idx] = value;
1305 }
1306
1307 if(validates(idx))
1308 {
1310 }
1311 else
1312 {
1313 r = false;
1314 }
1315 }
1316 else
1317 {
1318 bool changed(false);
1319 bool const append(multiple && idx >= static_cast<int>(f_value.size()));
1320 for(auto const & k : option_keys)
1321 {
1322 bool new_value(true);
1323 std::string const v(k + value);
1325 if(idx == -1)
1326 {
1327 f_value.push_back(v);
1328 changed = true;
1329 }
1330 else
1331 {
1332 if(f_value[idx] == v)
1333 {
1334 new_value = false;
1335 }
1336 else
1337 {
1338 changed = true;
1339 f_value[idx] = v;
1340 }
1341 }
1342 if(new_value)
1343 {
1344 if(validates(idx))
1345 {
1347 }
1348 else
1349 {
1350 r = false;
1351 }
1352 }
1353 }
1354 if(!changed)
1355 {
1356 return true;
1357 }
1358 }
1359
1360 return r;
1361}
1362
1363
1407 std::string const & value
1408 , string_list_t const & option_keys
1409 , option_source_t source)
1410{
1412 && option_keys.size() != 0)
1413 {
1414 throw getopt_logic_error(
1415 "option_info::set_multiple_value(): parameter --"
1416 + f_name
1417 + " does not support array keys.");
1418 }
1419
1421 {
1422 throw getopt_logic_error(
1423 "option_info::set_multiple_values(): called with SOURCE_UNDEFINED ("
1424 + std::to_string(static_cast<int>(source))
1425 + ").");
1426 }
1427
1430
1432 && result.size() > 1)
1433 {
1434 throw getopt_logic_error(
1435 "option_info::set_multiple_value(): parameter --"
1436 + f_name
1437 + " expects zero or one parameter. The set_multiple_value() function should not be called with parameters that only accept one value.");
1438 }
1439
1440 if(!option_keys.empty())
1441 {
1443 for(auto const & k : option_keys)
1444 {
1445 for(auto & r : result)
1446 {
1447 // note: the keys are expected to already include the ending ':'
1448 //
1449 keyed_result.push_back(k + r);
1450 }
1451 }
1452 result.swap(keyed_result);
1453 }
1454
1455 f_source = source;
1456 f_value.swap(result);
1457 f_integer.clear();
1458 f_double.clear();
1459
1460 bool const r(validate_all_values());
1461
1462 if(f_value != result)
1463 {
1464 // TBD: should we not call this function with all instances?
1465 // i.e. for(int idx(0); idx < f_value.size(); ++idx) ...
1466 // and check each value in f_value with the old value in
1467 // the result variable (knowing that result may be smaller)
1468 //
1469 value_changed(0);
1470 }
1471
1472 return r;
1473}
1474
1475
1495{
1496 bool all_valid(true);
1497 if(f_validator != nullptr)
1498 {
1499 for(size_t idx(0); idx < f_value.size(); )
1500 {
1501 if(!validates(idx))
1502 {
1503 // the value was removed, so do not increment `idx`
1504 //
1505 all_valid = false;
1506 }
1507 else
1508 {
1509 ++idx;
1510 }
1511 }
1512 }
1513
1514 return all_valid;
1515}
1516
1517
1534{
1535 return !f_value.empty();
1536}
1537
1538
1563{
1564 return f_source;
1565}
1566
1567
1585{
1586 g_trace_sources = trace;
1587}
1588
1589
1601{
1602 return f_trace_sources;
1603}
1604
1605
1613{
1614 g_configuration_filename = filename;
1615}
1616
1617
1633size_t option_info::size() const
1634{
1635 return f_value.size();
1636}
1637
1638
1663std::string option_info::get_value(int idx, bool raw) const
1664{
1665 if(static_cast<size_t>(idx) >= f_value.size())
1666 {
1667 throw getopt_undefined(
1668 "option_info::get_value(): no value at index "
1669 + std::to_string(idx)
1670 + " (idx >= "
1671 + std::to_string(f_value.size())
1672 + ") for --"
1673 + f_name
1674 + " so you can't get this value.");
1675 }
1676
1677 if(!raw
1678 && f_variables != nullptr
1680 {
1681 return f_variables->process_value(f_value[idx]);
1682 }
1683 else
1684 {
1685 return f_value[idx];
1686 }
1687}
1688
1689
1718{
1719 if(idx < 0)
1720 {
1721 throw getopt_logic_error("idx cannot be negative in find_value_index_by_key()");
1722 }
1723 if(f_value.empty())
1724 {
1725 throw getopt_undefined(
1726 "option_info::find_value_index_by_key(): --"
1727 + f_name
1728 + " has no values defined.");
1729 }
1730
1731 if(key.back() != ':')
1732 {
1733 key += ':';
1734 }
1735 int const max(f_value.size());
1736 for(; idx < max; ++idx)
1737 {
1738 if(f_value[idx].rfind(key, 0) == 0)
1739 {
1740 return idx;
1741 }
1742 }
1743
1744 return -1;
1745}
1746
1747
1773{
1774 if(static_cast<size_t>(idx) >= f_value.size())
1775 {
1776 throw getopt_undefined(
1777 "option_info::get_long(): no value at index "
1778 + std::to_string(idx)
1779 + " (idx >= "
1780 + std::to_string(f_value.size())
1781 + ") for --"
1782 + f_name
1783 + " so you can't get this value.");
1784 }
1785
1786 // since we may change the f_integer vector between threads,
1787 // add protection (i.e. most everything else is created at the
1788 // beginning so in the main thread)
1789 //
1790 cppthread::guard lock(get_global_mutex());
1791
1792 if(f_integer.size() != f_value.size())
1793 {
1794 // we did not yet convert to integers do that now
1795 //
1796 size_t const max(f_value.size());
1797 for(size_t i(f_integer.size()); i < max; ++i)
1798 {
1799 std::int64_t v;
1801 {
1802 f_integer.clear();
1803
1804 cppthread::log << cppthread::log_level_t::error
1805 << "invalid number ("
1806 << f_value[i]
1807 << ") in parameter --"
1808 << f_name
1809 << " at offset "
1810 << i
1811 << "."
1812 << cppthread::end;
1813 return -1;
1814 }
1815 f_integer.push_back(v);
1816 }
1817 }
1818
1819 return f_integer[idx];
1820}
1821
1822
1848{
1849 if(static_cast<size_t>(idx) >= f_value.size())
1850 {
1851 throw getopt_undefined(
1852 "option_info::get_double(): no value at index "
1853 + std::to_string(idx)
1854 + " (idx >= "
1855 + std::to_string(f_value.size())
1856 + ") for --"
1857 + f_name
1858 + " so you can't get this value.");
1859 }
1860
1861 // since we may change the f_integer vector between threads,
1862 // add protection (i.e. most everything else is created at the
1863 // beginning so in the main thread)
1864 //
1865 cppthread::guard lock(get_global_mutex());
1866
1867 if(f_double.size() != f_value.size())
1868 {
1869 // we did not yet convert to doubles do that now
1870 //
1871 size_t const max(f_value.size());
1872 for(size_t i(f_double.size()); i < max; ++i)
1873 {
1874 double v;
1876 {
1877 f_double.clear();
1878
1879 cppthread::log << cppthread::log_level_t::error
1880 << "invalid number ("
1881 << f_value[i]
1882 << ") in parameter --"
1883 << f_name
1884 << " at offset "
1885 << i
1886 << "."
1887 << cppthread::end;
1888 return -1;
1889 }
1890 f_double.push_back(v);
1891 }
1892 }
1893
1894 return f_double[idx];
1895}
1896
1897
1927{
1928 if(!always)
1929 {
1930 if(!is_defined())
1931 {
1932 return;
1933 }
1934 }
1935
1937}
1938
1939
1952
1953
1963{
1964 if(is_defined())
1965 {
1967 f_value.clear();
1968 f_integer.clear();
1969 f_double.clear();
1970
1971 value_changed(0);
1972 }
1973}
1974
1975
1988{
1989 cppthread::guard lock(get_global_mutex());
1990
1992 f_callbacks.emplace_back(f_next_callback_id, c);
1993 return f_next_callback_id;
1994}
1995
1996
2007{
2008 cppthread::guard lock(get_global_mutex());
2009
2010 auto it(std::find_if(
2011 f_callbacks.begin()
2012 , f_callbacks.end()
2013 , [id](auto e)
2014 {
2015 return e.f_id == id;
2016 }));
2017 if(it != f_callbacks.end())
2018 {
2019 f_callbacks.erase(it);
2020 }
2021}
2022
2023
2040{
2042
2044 callbacks.reserve(f_callbacks.size());
2045
2046 {
2047 cppthread::guard lock(get_global_mutex());
2049 }
2050
2051 for(auto e : callbacks)
2052 {
2053 e.f_callback(*this);
2054 }
2055}
2056
2057
2058
2067{
2068 if(!g_trace_sources)
2069 {
2070 return;
2071 }
2072
2073 std::string s;
2074 switch(f_source)
2075 {
2077 s = "command-line";
2078 break;
2079
2081 s = "configuration=\"" + g_configuration_filename + "\"";
2082 break;
2083
2085 s = "direct";
2086 break;
2087
2089 s = "dynamic";
2090 break;
2091
2093 s = "environment-variable";
2094 break;
2095
2097 // this happens on a reset or all the values were invalid
2098 //
2099 f_trace_sources.push_back(f_name + " [*undefined-source*]");
2100 return;
2101
2102 }
2103
2104 if(f_value.empty())
2105 {
2106 // this should never ever happen
2107 // (if f_value is empty then f_source == SOURCE_UNDEFINED)
2108 //
2109 f_trace_sources.push_back(f_name + " [*undefined-value*]"); // LCOV_EXCL_LINE
2110 }
2111 else
2112 {
2113 // TODO: change the algorithm, if the option supports
2114 //
2116 || static_cast<std::size_t>(idx) >= f_value.size())
2117 {
2118 f_trace_sources.push_back(f_name + "=" + f_value[0] + " [" + s + "]");
2119 }
2120 else
2121 {
2122 f_trace_sources.push_back(f_name + "[" + std::to_string(idx) + "]=" + f_value[idx] + " [" + s + "]");
2123 }
2124 }
2125}
2126
2127
2128} // namespace advgetopt
2129// vim: ts=4 sw=4 et
string_list_t get_section_name_list() const
Retrieve a list of section names.
void set_flags(flag_t flags)
Get the flags.
bool validates(int idx=0)
Check a value validity.
void unlock()
Unlock this value.
void add_flag(flag_t flag)
Make sure a given flag is set.
std::string get_environment_variable_name() const
Retrieve the environment variable name of this option.
bool is_default_option() const
Check whether this is the default option.
variables::pointer_t get_variables() const
Retrieve the list of variables held by this option info.
option_source_t f_source
void remove_default()
Remove the default value.
std::vector< long > f_integer
flag_t get_flags() const
Retrieve the flags.
std::string get_value(int idx=0, bool raw=false) const
Retrieve the value.
long get_long(int idx=0) const
Get the value as a long.
string_list_t f_value
bool has_value(std::string const &value) const
Check whether one of the values matches the input.
bool set_multiple_values(std::string const &value, string_list_t const &option_keys=string_list_t(), option_source_t source=option_source_t::SOURCE_DIRECT)
Set a multi-value at once.
validator::pointer_t f_validator
std::string f_default_value
callback_vector_t f_callbacks
bool is_defined() const
Check whether a value is defined.
string_list_t const & trace_sources() const
Get the trace of this option.
callback_id_t add_callback(callback_t const &c)
Add a callback to call on a change to this value.
std::vector< callback_entry_t > callback_vector_t
void lock(bool always=true)
Lock this value.
size_t size() const
Retrieve the number of values defined for this option.
pointer_t get_alias_destination() const
Get a link to the destination alias.
void set_environment_variable_name(std::string const &name)
Set the option specific environment variable name.
std::string const & get_default() const
Retrieve the default value.
void value_changed(int idx)
Call whenever the value changed so we can handle callbacks.
std::shared_ptr< option_info > pointer_t
Definition option_info.h:78
string_list_t f_trace_sources
void set_short_name(short_name_t short_name)
Assign a short name to an option.
void reset()
Reset this value.
void trace_source(int idx)
Remember the source information at of this last change.
pointer_t f_alias_destination
void set_help(std::string const &help)
Set the help string for this option.
bool has_default() const
Check whether this option has a default value.
bool get_environment_variable_value(std::string &value, char const *intro=nullptr) const
Retrieve the environment variable value of this option.
std::string get_section_name() const
Retrieve the name of the sections.
bool validate_all_values()
Validate all the values of this option_info object.
static void set_trace_sources(bool trace)
Whether the sources should be traced.
variables::pointer_t f_variables
void set_variables(variables::pointer_t vars)
Assign variables to this option info.
option_info(std::string const &name, short_name_t short_name=NO_SHORT_NAME)
Create a new option_info object.
std::function< void(option_info const &opt)> callback_t
Definition option_info.h:82
static void set_configuration_filename(std::string const &filename)
Save the filename of the current configuration file.
string_list_t const & get_multiple_separators() const
Retrieve the list of separators for this argument.
std::string get_basename() const
Retrieve the name of the option without any section names.
bool set_validator(std::string const &name_and_params)
Set the validator for this option.
option_source_t source() const
Return the source of this option info.
std::string const & get_name() const
Get the long name of the option.
int find_value_index_by_key(std::string key, int idx=0) const
Get the index at which a value with the given key is defined.
void set_default(std::string const &default_value)
Set the default value.
short_name_t get_short_name() const
Get the short name of the option.
bool set_value(int idx, std::string const &value, string_list_t const &option_keys=string_list_t(), option_source_t source=option_source_t::SOURCE_DIRECT)
Replace a value.
double get_double(int idx=0) const
Get the value as a double.
std::string f_environment_variable_name
bool has_flag(flag_t flag) const
Check whether a flag is set.
void remove_callback(callback_id_t id)
Remove a callback.
std::string const & get_help() const
Get the help string.
string_list_t f_multiple_separators
short_name_t f_short_name
bool add_value(std::string const &value, string_list_t const &option_keys=string_list_t(), option_source_t source=option_source_t::SOURCE_DIRECT)
Add a value to this option.
void set_alias_destination(pointer_t destination)
Set the alias option.
validator::pointer_t get_validator() const
Retrieve a pointer to the validator.
void remove_flag(flag_t flag)
Make sure a given flag is not set.
void set_multiple_separators(string_list_t const &separators)
Set the list of separators.
std::vector< double > f_double
static bool convert_string(std::string const &number, double &result)
Convert a string to a double value.
static bool convert_string(std::string const &number, std::int64_t &result)
Convert a string to an std::int64_t value.
static pointer_t create(std::string const &name, string_list_t const &data)
std::shared_ptr< validator > pointer_t
Definition validator.h:64
std::shared_ptr< variables > pointer_t
Definition variables.h:61
Definitions of the advanced getopt exceptions.
std::string g_configuration_filename
The filename of the configuration being processed.
The advgetopt environment to parse command line options.
Definition version.h:37
static constexpr flag_t GETOPT_FLAG_LOCK
Definition flags.h:80
void split_string(std::string const &str, string_list_t &result, string_list_t const &separators)
Split a string in sub-strings separated by separators.
Definition utils.cpp:347
static constexpr flag_t GETOPT_FLAG_ARRAY
Definition flags.h:57
constexpr flag_t option_flags_merge()
Definition flags.h:87
static constexpr flag_t GETOPT_FLAG_DYNAMIC_CONFIGURATION
Definition flags.h:48
static constexpr flag_t GETOPT_FLAG_PROCESS_VARIABLES
Definition flags.h:56
short_name_t string_to_short_name(std::string const &name)
Transform a string to a short name.
constexpr short_name_t NO_SHORT_NAME
Definition option_info.h:51
std::uint32_t flag_t
Definition flags.h:41
cppthread::mutex & get_global_mutex()
Get a global mutex.
Definition utils.cpp:123
char32_t short_name_t
Definition option_info.h:49
static constexpr flag_t GETOPT_FLAG_DEFAULT_OPTION
Definition flags.h:54
std::string short_name_to_string(short_name_t short_name)
Convert a short name to a UTF-8 string.
static constexpr flag_t GETOPT_FLAG_HAS_DEFAULT
Definition flags.h:55
static constexpr flag_t GETOPT_FLAG_MULTIPLE
Definition flags.h:53
std::string unquote(std::string const &s, std::string const &pairs)
Remove single (') or double (") quotes from a string.
Definition utils.cpp:168
std::string option_with_dashes(std::string const &s)
Convert the _ found in a string to - instead.
Definition utils.cpp:259
std::vector< std::string > string_list_t
Definition utils.h:41
static constexpr flag_t GETOPT_FLAG_ALIAS
Definition flags.h:50
Declaration of the option_info class used to record available options.
Declaration of validators which can be used to verify the parameters.
Declaration of validators which can be used to verify the parameters.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.