43 #ifndef _CRT_SECURE_NO_WARNINGS
44 #define _CRT_SECURE_NO_WARNINGS
65 std::string token =
"%i%";
67 while ((pos =
str.find(token, pos)) != std::string::npos)
69 str.replace(pos, token.length(), replace);
70 pos += replace.length();
78 void Diagnostics::ignoredNode(
const pugi::xml_node &node,
const std::string &msg)
80 warnings.push_back(std::string(
"XML Warning: ") + msg +
" [" + node.
path() +
"]");
82 void Diagnostics::unexpectedNode(
const pugi::xml_node &node,
const std::string &msg)
84 errors.push_back(std::string(
"XML Error: ") + msg +
" [" + node.
path() +
"]");
86 void Diagnostics::print(std::ostream &out)
const
88 for (std::list<std::string>::const_iterator iter = warnings.begin(); iter != warnings.end(); ++iter)
90 out << *iter << std::endl;
92 for (std::list<std::string>::const_iterator iter = errors.begin(); iter != errors.end(); ++iter)
94 out << *iter << std::endl;
99 bool parse<std::string>(
pugi::xml_node node, std::string &dst, Diagnostics &diag)
103 diag.unexpectedNode(node,
"cannot get string from null node");
109 diag.unexpectedNode(tnode,
"cannot get string from non pcdata node");
114 diag.unexpectedNode(node,
"node conatains more than just one text node");
121 bool write<std::string>(
pugi::xml_node node,
const std::string &src, Diagnostics &diag)
131 if (!parse<std::string>(node, ret, diag))
135 return fromString(ret, dst);
141 if (!parse<std::string>(node, ret, diag))
146 std::stringstream ss;
147 ss << std::hex << ret;
155 std::stringstream ss;
157 return write<std::string>(node, ss.str(), diag);
161 bool parse<unsigned>(
pugi::xml_node node,
unsigned &dst, Diagnostics &diag)
164 if (!parse<std::string>(node, ret, diag))
168 return fromString(ret, dst);
171 bool write<unsigned>(
pugi::xml_node node,
const unsigned &src, Diagnostics &diag)
173 std::stringstream ss;
175 return write<std::string>(node, ss.str(), diag);
179 bool parse_attr<std::string>(
pugi::xml_node node,
const std::string &attr_name, std::string &dst, Diagnostics &diag)
184 if (hasName(attr, attr_name))
192 diag.unexpectedNode(node, std::string(
"Duplicated attribute: ") + attr_name);
201 bool write_attr<std::string>(
pugi::xml_node node,
const std::string &attr_name,
const std::string &src,
206 if (hasName(attr, attr_name))
208 attr.set_value(src.c_str());
217 bool fromString<uint64_t>(
const std::string &
s,
uint64_t &val)
219 #if CXX0X_UP_SUPPORTED
220 static_assert(
sizeof(
uint64_t) <=
sizeof(
unsigned long long),
"cannot convert string to uint64_t with stoull");
223 val = std::stoull(
s);
231 unsigned long long tmp;
232 if (!sscanf(
s.c_str(),
"%llu", &tmp))
239 bool fromString<unsigned>(
const std::string &
s,
unsigned &val)
241 #if CXX0X_UP_SUPPORTED
244 val = (unsigned)std::stoull(
s);
252 if (!sscanf(
s.c_str(),
"%iu", &val))
260 const char *cname = node.
name();
263 return name == cname;
267 const char *cname = attr.
name();
270 return name == cname;
279 if (hasName(cnode, name))
284 diag.unexpectedNode(cnode,
"only one node with this name may exist");
#define static_assert(x, y)
contains XML related functions.
__device__ __2f16 float bool s
static __inline__ uint64_t
const char_t * name() const
xml_attribute next_attribute() const
bool set_value(const char_t *rhs)
string_t path(char_t delimiter='/') const
bool set_value(const char_t *rhs)
xml_node_type type() const
xml_node append_child(xml_node_type type=node_element)
xml_node first_child() const
xml_attribute append_attribute(const char_t *name)
xml_node next_sibling() const
const char_t * value() const
xml_attribute first_attribute() const
const char_t * name() const
void setCoreName(std::string &str)
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.