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
30namespace G
31{
32 class OptionReader ;
33}
34
35//| \class G::OptionReader
36/// Provides a static function to read options from a config file.
37///
39{
40public:
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
51public:
52 OptionReader() = delete ;
53} ;
54
55#endif
Provides a static function to read options from a config file.
Definition: goptionreader.h:39
static StringArray read(const G::Path &, std::size_t limit=1000U)
Reads options from file as a list of strings like "--foo=bar".
static std::size_t add(StringArray &out, const G::Path &, std::size_t limit=1000U)
Adds options read from file to an existing list.
A Path object represents a file system path.
Definition: gpath.h:82
Low-level classes.
Definition: garg.h:36
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstringarray.h:30
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Definition: ggettext.h:84