Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

parsing.h
Go to the documentation of this file.
1 /*
2 * Various string utils and parsing functions
3 * (C) 1999-2007,2013 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_PARSER_H__
9 #define BOTAN_PARSER_H__
10
11 #include <botan/types.h>
12 #include <string>
13 #include <vector>
14 #include <set>
15
16 #include <istream>
17 #include <functional>
18 #include <map>
19
20 namespace Botan {
21
22 /**
23 * Parse a SCAN-style algorithm name
24 * @param scan_name the name
25 * @return the name components
26 */
27 BOTAN_DLL std::vector<std::string>
28 parse_algorithm_name(const std::string& scan_name);
29
30 /**
31 * Split a string
32 * @param str the input string
33 * @param delim the delimitor
34 * @return string split by delim
35 */
36 BOTAN_DLL std::vector<std::string> split_on(
37 const std::string& str, char delim);
38
39 /**
40 * Split a string on a character predicate
41 * @param str the input string
42 * @param pred the predicate
43 */
44 BOTAN_DLL std::vector<std::string>
45 split_on_pred(const std::string& str,
46 std::function<bool (char)> pred);
47
48 /**
49 * Erase characters from a string
50 */
51 BOTAN_DLL std::string erase_chars(const std::string& str, const std::set<char>& chars);
52
53 /**
54 * Replace a character in a string
55 * @param str the input string
56 * @param from_char the character to replace
57 * @param to_char the character to replace it with
58 * @return str with all instances of from_char replaced by to_char
59 */
60 BOTAN_DLL std::string replace_char(const std::string& str,
61 char from_char,
62 char to_char);
63
64 /**
65 * Replace a character in a string
66 * @param str the input string
67 * @param from_chars the characters to replace
68 * @param to_char the character to replace it with
69 * @return str with all instances of from_chars replaced by to_char
70 */
71 BOTAN_DLL std::string replace_chars(const std::string& str,
72 const std::set<char>& from_chars,
73 char to_char);
74
75 /**
76 * Join a string
77 * @param strs strings to join
78 * @param delim the delimitor
79 * @return string joined by delim
80 */
81 BOTAN_DLL std::string string_join(const std::vector<std::string>& strs,
82 char delim);
83
84 /**
85 * Parse an ASN.1 OID
86 * @param oid the OID in string form
87 * @return OID components
88 */
89 BOTAN_DLL std::vector<uint32_t> parse_asn1_oid(const std::string& oid);
90
91 /**
92 * Compare two names using the X.509 comparison algorithm
93 * @param name1 the first name
94 * @param name2 the second name
95 * @return true if name1 is the same as name2 by the X.509 comparison rules
96 */
97 BOTAN_DLL bool x500_name_cmp(const std::string& name1,
98 const std::string& name2);
99
100 /**
101 * Convert a string to a number
102 * @param str the string to convert
103 * @return number value of the string
104 */
105 BOTAN_DLL uint32_t to_u32bit(const std::string& str);
106
107 /**
108 * Convert a time specification to a number
109 * @param timespec the time specification
110 * @return number of seconds represented by timespec
111 */
112 BOTAN_DLL uint32_t timespec_to_u32bit(const std::string& timespec);
113
114 /**
115 * Convert a string representation of an IPv4 address to a number
116 * @param ip_str the string representation
117 * @return integer IPv4 address
118 */
119 BOTAN_DLL uint32_t string_to_ipv4(const std::string& ip_str);
120
121 /**
122 * Convert an IPv4 address to a string
123 * @param ip_addr the IPv4 address to convert
124 * @return string representation of the IPv4 address
125 */
126 BOTAN_DLL std::string ipv4_to_string(uint32_t ip_addr);
127
128 std::map<std::string, std::string> BOTAN_DLL read_cfg(std::istream& is);
129
130 std::string BOTAN_DLL clean_ws(const std::string& s);
131
132 bool BOTAN_DLL host_wildcard_match(const std::string& wildcard, const std::string& host);
133
134
135 }
136
137 #endif
Botan::parse_algorithm_name
std::vector< std::string > parse_algorithm_name(const std::string &namex)
Definition: parsing.cpp:85
Botan::to_u32bit
uint32_t to_u32bit(const std::string &str)
Definition: parsing.cpp:18
Botan::x500_name_cmp
bool x500_name_cmp(const std::string &name1, const std::string &name2)
Definition: parsing.cpp:222
Botan::string_join
std::string string_join(const std::vector< std::string > &strs, char delim)
Definition: parsing.cpp:172
Botan::replace_chars
std::string replace_chars(const std::string &str, const std::set< char > &chars, char to_char)
Definition: parsing.cpp:313
Botan::erase_chars
std::string erase_chars(const std::string &str, const std::set< char > &chars)
Definition: parsing.cpp:302
Botan::split_on
std::vector< std::string > split_on(const std::string &str, char delim)
Definition: parsing.cpp:138
Botan::ipv4_to_string
std::string ipv4_to_string(uint32_t ip)
Definition: parsing.cpp:288
Botan::split_on_pred
std::vector< std::string > split_on_pred(const std::string &str, std::function< bool(char)> pred)
Definition: parsing.cpp:143
Botan::clean_ws
std::string BOTAN_DLL clean_ws(const std::string &s)
Definition: read_cfg.cpp:13
Botan::read_cfg
std::map< std::string, std::string > BOTAN_DLL read_cfg(std::istream &is)
Definition: read_cfg.cpp:28
Botan
Definition: alg_id.cpp:13
Botan::parse_asn1_oid
std::vector< uint32_t > parse_asn1_oid(const std::string &oid)
Definition: parsing.cpp:189
Botan::host_wildcard_match
bool host_wildcard_match(const std::string &issued, const std::string &host)
Definition: parsing.cpp:337
Botan::timespec_to_u32bit
uint32_t timespec_to_u32bit(const std::string &timespec)
Definition: parsing.cpp:54
Botan::string_to_ipv4
uint32_t string_to_ipv4(const std::string &str)
Definition: parsing.cpp:263
Botan::replace_char
std::string replace_char(const std::string &str, char from_char, char to_char)
Definition: parsing.cpp:326