A library for working with phylogenetic and population genetic data.
v0.32.0
utils/formats/xml/helper.cpp
Go to the documentation of this file.
1
/*
2
Genesis - A toolkit for working with phylogenetic data.
3
Copyright (C) 2014-2017 Lucas Czech
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
Contact:
19
Lucas Czech <lucas.czech@h-its.org>
20
Exelixis Lab, Heidelberg Institute for Theoretical Studies
21
Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22
*/
23
31
#include "
genesis/utils/formats/xml/helper.hpp
"
32
33
#include "
genesis/utils/text/string.hpp
"
34
35
namespace
genesis
{
36
namespace
utils {
37
38
// =================================================================================================
39
// Xml Helper Functions
40
// =================================================================================================
41
45
std::string
xml_escape
( std::string
const
& txt )
46
{
47
std::string res;
48
res =
utils::replace_all
( txt,
"<"
,
"<"
);
49
res =
utils::replace_all
( res,
">"
,
">"
);
50
res =
utils::replace_all
( res,
"&"
,
"&"
);
51
res =
utils::replace_all
( res,
"'"
,
"'"
);
52
res =
utils::replace_all
( res,
"\""
,
"""
);
53
return
res;
54
}
55
59
std::string
xml_deescape
( std::string
const
& txt )
60
{
61
std::string res;
62
res =
utils::replace_all
( txt,
"<"
,
"<"
);
63
res =
utils::replace_all
( res,
">"
,
">"
);
64
res =
utils::replace_all
( res,
"&"
,
"&"
);
65
res =
utils::replace_all
( res,
"'"
,
"'"
);
66
res =
utils::replace_all
( res,
"""
,
"\""
);
67
return
res;
68
}
69
70
std::string
xml_comment
( std::string
const
& content )
71
{
72
return
"<!-- "
+ content +
" -->"
;
73
}
74
75
}
// namespace utils
76
}
// namespace genesis
helper.hpp
genesis::utils::replace_all
std::string replace_all(std::string const &text, std::string const &search, std::string const &replace)
Return a copy of a string, where all occurrences of a search string are replaced by a replace string.
Definition:
string.cpp:727
string.hpp
Provides some commonly used string utility functions.
genesis::utils::xml_escape
std::string xml_escape(std::string const &txt)
Escape special XML characters.
Definition:
utils/formats/xml/helper.cpp:45
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition:
placement/formats/edge_color.cpp:42
genesis::utils::xml_comment
std::string xml_comment(std::string const &content)
Definition:
utils/formats/xml/helper.cpp:70
genesis::utils::xml_deescape
std::string xml_deescape(std::string const &txt)
De-escape special XML characters.
Definition:
utils/formats/xml/helper.cpp:59
lib
genesis
utils
formats
xml
helper.cpp
Generated on Mon Aug 5 2024 16:57:52 for genesis by
1.8.17