Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
pct.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Roc Streaming authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_address/pct.h
10
//! @brief Percent-encoding and -decoding.
11
12
#ifndef ROC_ADDRESS_PCT_H_
13
#define ROC_ADDRESS_PCT_H_
14
15
#include "
roc_core/attributes.h
"
16
#include "
roc_core/stddefs.h
"
17
#include "
roc_core/string_builder.h
"
18
19
namespace
roc
{
20
namespace
address
{
21
22
//! Percent-encoding mode.
23
enum
PctMode
{
24
//! Percent-encode all symbols that are not unreserved.
25
PctNonUnreserved
,
26
27
//! Percent-encode all symbols that are not allowed in host.
28
PctNonHost
,
29
30
//! Percent-encode all symbols that are not allowed in path.
31
PctNonPath
32
};
33
34
//! Percent-encode an UTF-8 string.
35
//
36
//! @b Parameters
37
//! - @p dst - destination buffer
38
//! - @p src - source string in UTF-8
39
//! - @p src_sz - source string size
40
//! - @p mode - encoding mode
41
//!
42
//! @remarks
43
//! The source string should NOT be null-terminated.
44
//! The source string size should NOT include the terminating zero byte.
45
ROC_ATTR_NODISCARD
bool
46
pct_encode
(
core::StringBuilder
& dst,
const
char
* src,
size_t
src_sz,
PctMode
mode);
47
48
//! Percent-decode an UTF-8 string.
49
//
50
//! @b Parameters
51
//! - @p dst - destination buffer
52
//! - @p src - source string in UTF-8
53
//! - @p src_sz - source string size
54
//!
55
//! @remarks
56
//! The source string should NOT be null-terminated.
57
//! The source string size should NOT include the terminating zero byte.
58
ROC_ATTR_NODISCARD
bool
59
pct_decode
(
core::StringBuilder
& dst,
const
char
* src,
size_t
src_sz);
60
61
}
// namespace address
62
}
// namespace roc
63
64
#endif
// ROC_ADDRESS_PCT_H_
attributes.h
Compiler attributes.
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::core::StringBuilder
String builder.
Definition
string_builder.h:34
roc::address
URIs and addresses.
roc::address::pct_encode
ROC_ATTR_NODISCARD bool pct_encode(core::StringBuilder &dst, const char *src, size_t src_sz, PctMode mode)
Percent-encode an UTF-8 string.
roc::address::pct_decode
ROC_ATTR_NODISCARD bool pct_decode(core::StringBuilder &dst, const char *src, size_t src_sz)
Percent-decode an UTF-8 string.
roc::address::PctMode
PctMode
Percent-encoding mode.
Definition
pct.h:23
roc::address::PctNonPath
@ PctNonPath
Percent-encode all symbols that are not allowed in path.
Definition
pct.h:31
roc::address::PctNonUnreserved
@ PctNonUnreserved
Percent-encode all symbols that are not unreserved.
Definition
pct.h:25
roc::address::PctNonHost
@ PctNonHost
Percent-encode all symbols that are not allowed in host.
Definition
pct.h:28
roc
Root namespace.
stddefs.h
Commonly used types and functions.
string_builder.h
String builder.
roc_address
pct.h
Generated by
1.17.0