-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.h
67 lines (52 loc) · 1.59 KB
/
Config.h
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
//*****************************************************************************
//
// Copyright (C) 2001 Steve Connet. All rights reserved.
//
// Source File Name : Config.h
// Author : Steve Connet
//
// Version : $Id: Config.h,v 1.3 2015/03/14 23:30:04 clu Exp $
//
// File Overview : Reads in the configuration file once and puts
// each name value pair into a map for quick
// retrieval.
//
// Revision History :
//
// $Log: Config.h,v $
// Revision 1.3 2015/03/14 23:30:04 clu
// astyle code formatter applied
//
// Revision 1.2 2002/01/11 03:41:49 sconnet
// *** empty log message ***
//
// Revision 1.1 2001/11/08 06:17:14 sconnet
// Initial revision
//
//
//*****************************************************************************
//#pragma interface
#ifndef __CONFIG_H_
#define __CONFIG_H_
#include <map>
#include <string>
#include <iostream>
//namespace ConnetUtils
//{
class Config
{
public:
friend std::ostream &operator<<(std::ostream &out, const Config &config);
private:
std::map<std::string, std::string> data;
int getValueAsInt(const std::string &name, int default_value);
std::string getValueAsStr(const std::string &name, const std::string &default_value);
public:
bool load(const std::string &file);
/* std::string operator()(const std::string& name, const std::string& default) */
/* { return getValueAsStr(name, default); } */
/* int operator()(const std::string& name, int default = 0) */
/* { return getValueAsInt(name, default); } */
};
//}
#endif // __CONFIG_H_