PolyBoRi
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
polybori
include
CVariableNames.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
//*****************************************************************************
42
//*****************************************************************************
43
44
// include basic definitions
45
#include "
pbori_defs.h
"
46
47
// get standard vector functionality
48
#include <vector>
49
50
// get standard string functionalities
51
#include <string>
52
#include <sstream>
53
54
55
#ifndef CVariableNames_h_
56
#define CVariableNames_h_
57
58
BEGIN_NAMESPACE_PBORI
59
60
class
CVariableNames
{
61
public
:
62
64
65
typedef
CTypes::size_type
size_type
;
66
typedef
CTypes::idx_type
idx_type
;
68
70
typedef
CTypes::vartext_type
vartext_type
;
71
73
typedef
std::string
varname_type
;
74
76
typedef
std::vector<varname_type>
storage_type
;
77
79
typedef
storage_type::reference
reference
;
80
82
typedef
vartext_type
const_reference
;
83
85
typedef
CVariableNames
self
;
86
88
CVariableNames
(
size_type
nvars): m_data(nvars) { reset(); }
89
91
CVariableNames
(
const
self
& rhs): m_data(rhs.m_data) { }
92
94
void
reset(
idx_type
idx = 0);
95
97
const_reference
operator[]
(
idx_type
idx)
const
{
98
99
if
UNLIKELY
(
size_type
(idx) >= m_data.size())
100
return
undefName();
101
return
m_data[idx].c_str();
102
}
103
105
void
set
(
idx_type
idx,
const
varname_type
& varname) {
106
107
size_type
nlen = m_data.size();
108
109
if
UNLIKELY
((
size_type
)idx >= nlen) {
110
m_data.resize((
size_type
)idx + 1);
111
reset((
idx_type
)nlen);
112
}
113
114
m_data[idx] = varname;
115
}
116
117
protected
:
118
static
const_reference
undefName
() {
return
"UNDEF"
; }
119
120
private
:
121
storage_type m_data;
122
};
123
124
inline
125
void
CVariableNames::reset(
idx_type
idx) {
126
127
idx_type
nlen = (
idx_type
)m_data.size();
128
129
for
(; idx < nlen; ++idx){
130
std::ostringstream sstrg;
131
sstrg <<
"x("
<< idx <<
')'
;
132
m_data[idx] = sstrg.str();
133
}
134
}
135
136
137
END_NAMESPACE_PBORI
138
139
#endif
Generated on Wed Apr 16 2014 05:41:14 for PolyBoRi by
1.8.1.2