forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttributes.h
More file actions
executable file
·125 lines (92 loc) · 3.25 KB
/
Attributes.h
File metadata and controls
executable file
·125 lines (92 loc) · 3.25 KB
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
//
// Attributes.h
//
// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Attributes.h#2 $
//
// Library: CppParser
// Package: Attributes
// Module: Attributes
//
// Definition of the Attributes class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef CppParser_Attributes_INCLUDED
#define CppParser_Attributes_INCLUDED
#include "Poco/CppParser/CppParser.h"
#include <map>
namespace Poco {
namespace CppParser {
class CppParser_API Attributes
/// This class stores attributes for a symbol table entry.
/// Attributes are simple name-value pairs, where both
/// name and values are strings.
{
public:
typedef std::map<std::string, std::string> AttrMap;
typedef AttrMap::const_iterator Iterator;
Attributes();
/// Creates the Attributes object.
Attributes(const Attributes& attrs);
/// Creates the Attributes object by copying another one.
~Attributes();
/// Destroys the Attributes object.
Attributes& operator = (const Attributes& attrs);
/// Assignment operator.
bool has(const std::string& name) const;
/// Returns true if an attribute with the given name exists.
std::string getString(const std::string& name) const;
/// Returns the attribute's value as a string.
///
/// Throws a Poco::NotFoundException if the attribute does not exist.
std::string getString(const std::string& name, const std::string& defaultValue) const;
/// Returns the attribute's value as a string, if it exists.
/// Returns the defaultValue if the attribute does not exist.
int getInt(const std::string& name) const;
/// Returns the attribute's value as an integer.
///
/// Throws a Poco::NotFoundException if the attribute does not exist.
/// Throws a Poco::SyntaxException if the stored value is not an integer.
int getInt(const std::string& name, int defaultValue) const;
/// Returns the attribute's value as an integer, if it exists.
/// Returns the defaultValue if the attribute does not exist.
///
/// Throws a Poco::SyntaxException if the stored value is not an integer.
bool getBool(const std::string& name) const;
/// Returns the attribute's value as a boolean.
/// The returned value is 'true', iff the stored value is not "false".
///
/// Throws a Poco::NotFoundException if the attribute does not exist.
bool getBool(const std::string& name, bool defaultValue) const;
/// Returns the attribute's value as a boolean, if it exists.
/// The returned value is 'true', iff the stored value is not "false".
void set(const std::string& name, const std::string& value);
/// Sets the value of an attribute.
void remove(const std::string& name);
/// Removes the attribute with the given name.
/// Does nothing if the attribute does not exist.
const std::string& operator [] (const std::string& name) const;
std::string& operator [] (const std::string& name);
Iterator begin() const;
Iterator end() const;
void clear();
/// Clears all attributes.
private:
AttrMap _map;
};
//
// inlines
//
inline Attributes::Iterator Attributes::begin() const
{
return _map.begin();
}
inline Attributes::Iterator Attributes::end() const
{
return _map.end();
}
} } // namespace Poco::CppParser
#endif // CppParser_Attributes_INCLUDED