forked from objectcomputing/mFAST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml_util.h
More file actions
32 lines (27 loc) · 921 Bytes
/
xml_util.h
File metadata and controls
32 lines (27 loc) · 921 Bytes
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
// Copyright (c) 2016, Huang-Ming Huang, Object Computing, Inc.
// All rights reserved.
//
// This file is part of mFAST.
// See the file license.txt for licensing information.
#pragma once
#include "tinyxml2.h"
#include "../arena_allocator.h"
namespace mfast {
namespace xml_parser {
using namespace tinyxml2;
inline const char *get_optional_attr(const XMLElement &element,
const char *attr_name,
const char *default_value) {
const XMLAttribute *attr = element.FindAttribute(attr_name);
return attr ? attr->Value() : default_value;
}
inline const char *string_dup(const char *str, arena_allocator &alloc) {
if (str == nullptr || str[0] == '\x0')
return "";
std::size_t len = std::strlen(str) + 1;
return reinterpret_cast<const char *>(
std::memcpy(alloc.allocate(len), str, len));
;
}
} /* xml_parser */
} /* mfast */