aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/string_escape.h
blob: 3ad926dafc43011454fe131cadffb4e5fca2ed3e (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/string.h>
#include <iosfwd>

namespace vespalib {

/**
 * Returns input string but where the following characters are escaped:
 *   - all control chars < char value 32
 *   - <, >, &, " and '
 */
[[nodiscard]] vespalib::string xml_attribute_escaped(vespalib::stringref s);

/**
 * Returns input string but where the following characters are escaped:
 *   - all control chars < char value 32, _except_ linebreak
 *   - <, > and &
 */
[[nodiscard]] vespalib::string xml_content_escaped(vespalib::stringref s);
void write_xml_content_escaped(vespalib::asciistream& out, vespalib::stringref s);
void write_xml_content_escaped(std::ostream& out, vespalib::stringref s);

}