E-MailRelay

goptionreader.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file goptionreader.h
19///
20
21#ifndef G_OPTION_READER_H
22#define G_OPTION_READER_H
23
24#include "gdef.h"
25#include "gstringarray.h"
26#include "gexception.h"
27#include "ggettext.h"
28#include "gpath.h"
29
30 namespace G
31{
32 class OptionReader ;
33}
34
35//| \class G::OptionReader
36/// Provides a static function to read options from a config file.
37///
38 class G::OptionReader
39{
40 public:
41 G_EXCEPTION( FileError , tx("error reading configuration file") )
42
43 static StringArray read( const G::Path & , std::size_t limit = 1000U ) ;
44 ///< Reads options from file as a list of strings like "--foo=bar".
45 ///< Throws on error.
46
47 static std::size_t add( StringArray & out , const G::Path & , std::size_t limit = 1000U ) ;
48 ///< Adds options read from file to an existing list.
49 ///< Returns the number of options added.
50
51 public:
52 OptionReader() = delete ;
53} ;
54
55#endif
G::OptionReader
Provides a static function to read options from a config file.
Definition: goptionreader.h:39
G::OptionReader::read
static StringArray read(const G::Path &, std::size_t limit=1000U)
Reads options from file as a list of strings like "--foo=bar".
Definition: goptionreader.cpp:30
G::OptionReader::add
static std::size_t add(StringArray &out, const G::Path &, std::size_t limit=1000U)
Adds options read from file to an existing list.
Definition: goptionreader.cpp:37
G::Path
A Path object represents a file system path.
Definition: gpath.h:82
gexception.h
ggettext.h
gpath.h
gstringarray.h
G
Low-level classes.
Definition: garg.h:36
G::StringArray
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstringarray.h:30
G::tx
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Definition: ggettext.h:84