/usr/include/varconf-1.0/varconf/config.h is in libvarconf-dev 1.0.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | /*
* config.h - interface for configuration class
* Copyright (C) 2001, Stefanus Du Toit, Joseph Zupko
* (C) 2002-2006 Alistair Riddoch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: Joseph Zupko
* jaz147@psu.edu
*
* 189 Reese St.
* Old Forge, PA 18518
*/
#ifndef VARCONF_CONFIG_H
#define VARCONF_CONFIG_H
#include <varconf/varconf_defs.h>
#include <varconf/parse_error.h>
#include <varconf/variable.h>
#include <sigc++/trackable.h>
#include <sigc++/signal.h>
#include <iostream>
#include <map>
#include <string>
namespace varconf {
typedef std::map< std::string, Variable > sec_map;
typedef std::map< std::string, sec_map> conf_map;
typedef std::map< char, std::pair<std::string, bool> > parameter_map;
class VARCONF_API Config : virtual protected sigc::trackable {
public:
// Allows use as a singleton, if desired.
static Config* inst();
Config() { }
// New Config object, but deep-copies the m_conf and m_par_lookup of existing,
// passed Config object.
Config(const Config & conf);
virtual ~Config();
VARCONF_API friend std::ostream & operator <<(std::ostream & out, Config & conf);
VARCONF_API friend std::istream & operator >>(std::istream & in, Config & conf);
VARCONF_API friend bool operator ==(const Config & one, const Config & two);
// Converts all nonalphanumeric characters in str except ``-'' and ``_'' to
// ``_''; converts caps in str to lower-case.
static void clean(std::string & str);
// Returns true if specified key exists under specified section.
bool find(const std::string & section, const std::string & key = "") const;
// Returns true if specified key exists under specified section and is
// successfully deleted.
bool erase(const std::string & section, const std::string & key = "");
// Writes to the specified output stream.
// Why isn't this protected?
bool writeToStream(std::ostream & out, Scope scope_mask) const;
// Gets, sets conf info based on options passed via command line.
int getCmdline(int argc, char** argv, Scope scope = INSTANCE);
// Gets, stores a name/value pair from the environment variable with
// name == prefix.
// prefix is case-sensitive!
void getEnv(const std::string & prefix, Scope scope = INSTANCE);
// Writes conf map to specified file. Returns true on success.
bool writeToFile(const std::string & filename,
Scope scopeMask = (Scope)(GLOBAL | USER | INSTANCE)) const;
// Reads contents of specified file and set into conf map. Returns
// true on success.
bool readFromFile(const std::string & filename, Scope scope = USER);
// Ensures specified filestream is properly formatted.
// Why isn't this protected?
void parseStream(std::istream & in, Scope scope) throw (ParseError);
// Wrapper for find(section)
bool findSection(const std::string & section) const;
// Wrapper for find(section, key)
bool findItem(const std::string & section, const std::string & key) const;
// Returns value of specified section.
const sec_map & getSection(const std::string & section);
// Returns value of specified key under specified section.
Variable getItem(const std::string & section, const std::string & key) const;
// Set the short name for a given long name to be used with short args.
void setParameterLookup(char s_name, const std::string & l_name,
bool value = false);
// If key isn't null, clean() section and key and set variable.
void setItem(const std::string & section, const std::string & key,
const Variable & item, Scope scope = INSTANCE);
// Accessor for the contained sections.
const conf_map& getSections() const;
sigc::signal<void> sig;
sigc::signal<void, const char*> sige;
sigc::signal<void, const std::string&, const std::string&> sigv;
sigc::signal<void, const std::string&, const std::string&, Config&> sigsv;
// libsigc++ signals; in order: standard callback signal, error signal,
// verbose callback signal and "super-verbose" callback signal.
private:
static Config* m_instance;
conf_map m_conf;
parameter_map m_par_lookup;
};
VARCONF_API std::ostream & operator <<(std::ostream & out, Config & conf);
VARCONF_API std::istream & operator >>(std::istream & in, Config & conf);
VARCONF_API bool operator ==(const Config & one, const Config & two);
} // namespace varconf
#endif // VARCONF_CONFIG_H
|