Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | List of all members
Botan::Data_Store Class Referencefinal

`#include <datastor.h>`

## Public Member Functions
void | add (const std::multimap< std::string, std::string > &)
void | add (const std::string &, const secure_vector< uint8_t > &)
void | add (const std::string &, const std::string &)
void | add (const std::string &, const std::vector< uint8_t > &)
void | add (const std::string &, uint32_t)
std::vector< std::string > | get (const std::string &) const
std::string | get1 (const std::string &key) const
std::string | get1 (const std::string &key, const std::string &default_value) const
std::vector< uint8_t > | get1_memvec (const std::string &) const
uint32_t | get1_uint32 (const std::string &, uint32_t=0) const
bool | has_value (const std::string &) const
bool | operator== (const Data_Store &) const
std::multimap< std::string, std::string > | search_for (std::function< bool(std::string, std::string)> predicate) const

## Detailed Description

Data Store

This class is used internally by the library, and exposed for ABI reasons. There is no reason for applications to use this type directly. It will be removed in a future major release.

Definition at line 28 of file datastor.h.

## Member Function Documentation

## ◆ add() [1/5]

void Botan::Data_Store::add | ( | const std::multimap< std::string, std::string > & | in | ) |

Definition at line 154 of file datastor.cpp.

155 {
156 std::multimap<std::string, std::string>::const_iterator i = in.begin();
157 while(i != in.end())
158 {
159 m_contents.insert(*i);
160 ++i;
161 }
162 }

Referenced by add(), and Botan::Extensions::contents_to().

## ◆ add() [2/5]

void Botan::Data_Store::add | ( | const std::string & | key,
|  | const secure_vector< uint8_t > & | val
| ) |  |

Definition at line 141 of file datastor.cpp.

142 {
143 add(key, hex_encode(val.data(), val.size()));
144 }
Botan::Data_Store::add
void add(const std::multimap< std::string, std::string > &)
Definition: datastor.cpp:154
Botan::hex_encode
void hex_encode(char output[], const uint8_t input[], size_t input_length, bool uppercase)
Definition: hex.cpp:31

References add(), and Botan::hex_encode().

## ◆ add() [3/5]

void Botan::Data_Store::add | ( | const std::string & | key,
|  | const std::string & | val
| ) |  |

Definition at line 125 of file datastor.cpp.

126 {
127 multimap_insert(m_contents, key, val);
128 }
Botan::multimap_insert
void multimap_insert(std::multimap< K, V > &multimap, const K &key, const V &value)
Definition: stl_util.h:76

References Botan::multimap_insert().

## ◆ add() [4/5]

void Botan::Data_Store::add | ( | const std::string & | key,
|  | const std::vector< uint8_t > & | val
| ) |  |

Definition at line 146 of file datastor.cpp.

147 {
148 add(key, hex_encode(val.data(), val.size()));
149 }

References add(), and Botan::hex_encode().

## ◆ add() [5/5]

void Botan::Data_Store::add | ( | const std::string & | key,
|  | uint32_t | val
| ) |  |

Definition at line 133 of file datastor.cpp.

134 {
135 add(key, std::to_string(val));
136 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213

References add(), and Botan::ASN1::to_string().

## ◆ get()

std::vector< std::string > Botan::Data_Store::get | ( | const std::string & | looking_for | ) | const

Definition at line 50 of file datastor.cpp.

51 {
52 std::vector<std::string> out;
53 auto range = m_contents.equal_range(looking_for);
54 for(auto i = range.first; i != range.second; ++i)
55 out.push_back(i->second);
56 return out;
57 }

Referenced by get1(), get1_memvec(), and get1_uint32().

## ◆ get1() [1/2]

std::string Botan::Data_Store::get1 | ( | const std::string & | key | ) | const

Definition at line 62 of file datastor.cpp.

63 {
64 std::vector<std::string> vals = get(key);
65
66 if(vals.empty())
67 throw Invalid_State("Data_Store::get1: No values set for " + key);
68 if(vals.size() > 1)
69 throw Invalid_State("Data_Store::get1: More than one value for " + key);
70
71 return vals[0];
72 }
Botan::Data_Store::get
std::vector< std::string > get(const std::string &) const
Definition: datastor.cpp:50

References get().

## ◆ get1() [2/2]

std::string Botan::Data_Store::get1 | ( | const std::string & | key,
|  | const std::string & | default_value
| ) |  | const

Definition at line 74 of file datastor.cpp.

76 {
77 std::vector<std::string> vals = get(key);
78
79 if(vals.size() > 1)
80 throw Invalid_State("Data_Store::get1: More than one value for " + key);
81
82 if(vals.empty())
83 return default_value;
84
85 return vals[0];
86 }

References get().

## ◆ get1_memvec()

std::vector< uint8_t > Botan::Data_Store::get1_memvec | ( | const std::string & | key | ) | const

Definition at line 92 of file datastor.cpp.

93 {
94 std::vector<std::string> vals = get(key);
95
96 if(vals.empty())
97 return std::vector<uint8_t>();
98
99 if(vals.size() > 1)
100 throw Invalid_State("Data_Store::get1_memvec: Multiple values for " +
101 key);
102
103 return hex_decode(vals[0]);
104 }
Botan::hex_decode
size_t hex_decode(uint8_t output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
Definition: hex.cpp:89

References get(), and Botan::hex_decode().

## ◆ get1_uint32()

uint32_t Botan::Data_Store::get1_uint32 | ( | const std::string & | key,
|  | uint32_t | default_val = `0`
| ) |  | const

Definition at line 109 of file datastor.cpp.

111 {
112 std::vector<std::string> vals = get(key);
113
114 if(vals.empty())
115 return default_val;
116 else if(vals.size() > 1)
117 throw Invalid_State("Data_Store::get1_uint32: Multiple values for " + key);
118
119 return to_u32bit(vals[0]);
120 }
Botan::to_u32bit
uint32_t to_u32bit(const std::string &str)
Definition: parsing.cpp:35

References get(), and Botan::to_u32bit().

## ◆ has_value()

bool Botan::Data_Store::has_value | ( | const std::string & | key | ) | const

Definition at line 27 of file datastor.cpp.

28 {
29 return (m_contents.lower_bound(key) != m_contents.end());
30 }

## ◆ operator==()

bool Botan::Data_Store::operator== | ( | const Data_Store & | other | ) | const

A search function

Definition at line 19 of file datastor.cpp.

20 {
21 return (m_contents == other.m_contents);
22 }

## ◆ search_for()

std::multimap< std::string, std::string > Botan::Data_Store::search_for | ( | std::function< bool(std::string, std::string)> | predicate | ) | const

Definition at line 35 of file datastor.cpp.

37 {
38 std::multimap<std::string, std::string> out;
39
40 for(auto i = m_contents.begin(); i != m_contents.end(); ++i)
41 if(predicate(i->first, i->second))
42 out.insert(std::make_pair(i->first, i->second));
43
44 return out;
45 }

Referenced by Botan::create_alt_name(), and Botan::create_dn().

The documentation for this class was generated from the following files:

- src/lib/x509/datastor.h
- src/lib/x509/datastor.cpp