Botan 1.10.17
Botan::Data_Store Class Reference

#include <datastor.h>

Classes

class  Matcher

Public Member Functions

void add (const std::multimap< std::string, std::string > &)
void add (const std::string &, const MemoryRegion< byte > &)
void add (const std::string &, const std::string &)
void add (const std::string &, u32bit)
std::vector< std::string > get (const std::string &) const
std::string get1 (const std::string &) const
MemoryVector< byteget1_memvec (const std::string &) const
u32bit get1_u32bit (const std::string &, u32bit=0) const
bool has_value (const std::string &) const
bool operator== (const Data_Store &) const
std::multimap< std::string, std::string > search_with (const Matcher &) const

Detailed Description

Data Store

Definition at line 22 of file datastor.h.

Member Function Documentation

◆ add() [1/4]

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

Definition at line 161 of file datastor.cpp.

162 {
163 std::multimap<std::string, std::string>::const_iterator i = in.begin();
164 while(i != in.end())
165 {
166 contents.insert(*i);
167 ++i;
168 }
169 }

Referenced by add(), and add().

◆ add() [2/4]

void Botan::Data_Store::add ( const std::string & key,
const MemoryRegion< byte > & val )

Definition at line 153 of file datastor.cpp.

154 {
155 add(key, hex_encode(&val[0], val.size()));
156 }
void add(const std::multimap< std::string, std::string > &)
Definition datastor.cpp:161
void hex_encode(char output[], const byte input[], size_t input_length, bool uppercase)
Definition hex.cpp:14

References add(), Botan::hex_encode(), and Botan::MemoryRegion< T >::size().

◆ add() [3/4]

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

Definition at line 137 of file datastor.cpp.

138 {
139 multimap_insert(contents, key, val);
140 }
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/4]

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

Definition at line 145 of file datastor.cpp.

146 {
147 add(key, to_string(val));
148 }
std::string to_string(u64bit n, size_t min_len)
Definition parsing.cpp:42

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

◆ get()

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

Definition at line 72 of file datastor.cpp.

73 {
74 typedef std::multimap<std::string, std::string>::const_iterator iter;
75
76 std::pair<iter, iter> range = contents.equal_range(looking_for);
77
78 std::vector<std::string> out;
79 for(iter i = range.first; i != range.second; ++i)
80 out.push_back(i->second);
81 return out;
82 }

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

◆ get1()

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

Definition at line 87 of file datastor.cpp.

88 {
89 std::vector<std::string> vals = get(key);
90
91 if(vals.empty())
92 throw Invalid_State("Data_Store::get1: Not values for " + key);
93 if(vals.size() > 1)
94 throw Invalid_State("Data_Store::get1: More than one value for " + key);
95
96 return vals[0];
97 }
std::vector< std::string > get(const std::string &) const
Definition datastor.cpp:72
Invalid_State(const std::string &err)
Definition exceptn.h:27

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

◆ get1_memvec()

MemoryVector< byte > Botan::Data_Store::get1_memvec ( const std::string & key) const

Definition at line 103 of file datastor.cpp.

104 {
105 std::vector<std::string> vals = get(key);
106
107 if(vals.empty())
108 return MemoryVector<byte>();
109
110 if(vals.size() > 1)
111 throw Invalid_State("Data_Store::get1_memvec: Multiple values for " +
112 key);
113
114 return hex_decode(vals[0]);
115 }
size_t hex_decode(byte output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
Definition hex.cpp:55

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

◆ get1_u32bit()

u32bit Botan::Data_Store::get1_u32bit ( const std::string & key,
u32bit default_val = 0 ) const

Definition at line 120 of file datastor.cpp.

122 {
123 std::vector<std::string> vals = get(key);
124
125 if(vals.empty())
126 return default_val;
127 else if(vals.size() > 1)
128 throw Invalid_State("Data_Store::get1_u32bit: Multiple values for " +
129 key);
130
131 return to_u32bit(vals[0]);
132 }
u32bit to_u32bit(const std::string &number)
Definition parsing.cpp:18

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

Referenced by Botan::CRL_Entry::decode_from().

◆ has_value()

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

Definition at line 37 of file datastor.cpp.

38 {
39 return (contents.lower_bound(key) != contents.end());
40 }

◆ operator==()

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

Definition at line 29 of file datastor.cpp.

30 {
31 return (contents == other.contents);
32 }

◆ search_with()

std::multimap< std::string, std::string > Botan::Data_Store::search_with ( const Matcher & matcher) const

Definition at line 46 of file datastor.cpp.

47 {
48 std::multimap<std::string, std::string> out;
49
50 std::multimap<std::string, std::string>::const_iterator i =
51 contents.begin();
52
53 while(i != contents.end())
54 {
55 if(matcher(i->first, i->second))
56 {
57 std::pair<std::string, std::string> p(
58 matcher.transform(i->first, i->second));
59
60 multimap_insert(out, p.first, p.second);
61 }
62
63 ++i;
64 }
65
66 return out;
67 }

References Botan::multimap_insert(), and Botan::Data_Store::Matcher::transform().

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


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