libzypp: zypp-core/parser/xml/XmlEscape.h Source File

libzypp 17.38.11

XmlEscape.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_PARSER_XML_XMLESCAPE_H
13#define ZYPP_PARSER_XML_XMLESCAPE_H
14
15#include <sstream>
16#include <string>
17#include <zypp-core/Globals.h>
18
20namespace zypp
21{
23 namespace xml
24 {
26 namespace detail
27 {
28 struct ZYPP_API EscapedString
29 {
30 EscapedString( const std::string & in_r ) : _in( in_r ) {}
31 std::ostream & dumpOn( std::ostream & str ) const;
32 std::string asString() const
33 { std::ostringstream str; dumpOn( str ); return str.str(); }
34 operator std::string() const
35 { return asString(); }
36 private:
37 const std::string & _in;
38 };
39
41 inline std::ostream & operator<<( std::ostream & str, const EscapedString & obj )
42 { return obj.dumpOn( str ); }
43
44 } // detail
46
51 ZYPP_API inline detail::EscapedString escape( const std::string & in_r )
52 { return detail::EscapedString( in_r ); }
53
54#ifdef __cpp_lib_string_view
55 inline std::string escape( std::string_view in_r )
56 { return escape( std::string(in_r) ); }
57#endif
58
60 std::string unescape( const std::string & in_r ) ZYPP_API;
61
62 } // namespace xml
64} // namespace zypp
66#endif // ZYPP_PARSER_XML_XMLESCAPE_H
Globals.h
Provides API related macros.
ZYPP_API
#define ZYPP_API
Definition Globals.h:69
str
String related utilities and Regular expression matching.
zypp::xml::detail
Definition XmlEscape.cc:78
zypp::xml::detail::operator<<
std::ostream & operator<<(std::ostream &str, const EscapedString &obj)
relates: EscapedString Stream output
Definition XmlEscape.h:41
zypp::xml
Definition libxmlfwd.cc:22
zypp::xml::escape
ZYPP_API detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Definition XmlEscape.h:51
zypp::xml::unescape
std::string unescape(const std::string &in_r)
Unescape xml special charaters (& -> &; from IoBind library).
Definition XmlEscape.cc:113
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589
zypp::xml::detail::EscapedString
Definition XmlEscape.h:29
zypp::xml::detail::EscapedString::dumpOn
std::ostream & dumpOn(std::ostream &str) const
Definition XmlEscape.cc:79
zypp::xml::detail::EscapedString::asString
std::string asString() const
Definition XmlEscape.h:32
zypp::xml::detail::EscapedString::EscapedString
EscapedString(const std::string &in_r)
Definition XmlEscape.h:30
zypp::xml::detail::EscapedString::_in
const std::string & _in
Definition XmlEscape.h:37