Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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/stddefs.h"
17
18namespace roc {
19namespace address {
20
21//! Percent-encoding mode.
22enum PctMode {
23 //! Percent-encode all symbols that are not unreserved.
25
26 //! Percent-encode all symbols that are not allowed in host.
28
29 //! Percent-encode all symbols that are not allowed in path.
31};
32
33//! Percent-encode an UTF-8 string.
34//
35//! @b Parameters
36//! - @p dst - destination buffer
37//! - @p src - source string in UTF-8
38//! - @p src_sz - source string size
39//! - @p mode - encoding mode
40//!
41//! @remarks
42//! The source string should NOT be null-terminated.
43//! The source string size should NOT include the terminating zero byte.
44bool pct_encode(core::StringBuilder& dst, const char* src, size_t src_sz, PctMode mode);
45
46//! Percent-decode an UTF-8 string.
47//
48//! @b Parameters
49//! - @p dst - destination buffer
50//! - @p src - source string in UTF-8
51//! - @p src_sz - source string size
52//!
53//! @remarks
54//! The source string should NOT be null-terminated.
55//! The source string size should NOT include the terminating zero byte.
56bool pct_decode(core::StringBuilder& dst, const char* src, size_t src_sz);
57
58} // namespace address
59} // namespace roc
60
61#endif // ROC_ADDRESS_PCT_H_
bool pct_encode(core::StringBuilder &dst, const char *src, size_t src_sz, PctMode mode)
Percent-encode an UTF-8 string.
bool pct_decode(core::StringBuilder &dst, const char *src, size_t src_sz)
Percent-decode an UTF-8 string.
PctMode
Percent-encoding mode.
Definition pct.h:22
@ PctNonPath
Percent-encode all symbols that are not allowed in path.
Definition pct.h:30
@ PctNonUnreserved
Percent-encode all symbols that are not unreserved.
Definition pct.h:24
@ PctNonHost
Percent-encode all symbols that are not allowed in host.
Definition pct.h:27
Root namespace.
Commonly used types and functions.
String builder.