Botan  1.10.9
Classes | Public Member Functions | List of all members
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 std::string &)
 
void add (const std::string &, u32bit)
 
void add (const std::string &, const MemoryRegion< byte > &)
 
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

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

Definition at line 161 of file datastor.cpp.

Referenced by add().

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  }
void Botan::Data_Store::add ( const std::string &  key,
const std::string &  val 
)

Definition at line 137 of file datastor.cpp.

References Botan::multimap_insert().

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
void Botan::Data_Store::add ( const std::string &  key,
u32bit  val 
)

Definition at line 145 of file datastor.cpp.

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

146  {
147  add(key, to_string(val));
148  }
std::string to_string(u64bit n, size_t min_len)
Definition: parsing.cpp:42
void add(const std::multimap< std::string, std::string > &)
Definition: datastor.cpp:161
void Botan::Data_Store::add ( const std::string &  key,
const MemoryRegion< byte > &  val 
)

Definition at line 153 of file datastor.cpp.

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

154  {
155  add(key, hex_encode(&val[0], val.size()));
156  }
size_t size() const
Definition: secmem.h:29
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
std::vector< std::string > Botan::Data_Store::get ( const std::string &  looking_for) const

Definition at line 72 of file datastor.cpp.

Referenced by Botan::PKCS10_Request::ex_constraints(), Botan::X509_Certificate::ex_constraints(), Botan::X509_Certificate::issuer_info(), Botan::X509_Certificate::policies(), and Botan::X509_Certificate::subject_info().

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  }
std::string Botan::Data_Store::get1 ( const std::string &  key) const

Definition at line 87 of file datastor.cpp.

Referenced by Botan::PKCS10_Request::challenge_password(), Botan::X509_Certificate::end_time(), Botan::X509_CRL::next_update(), Botan::PKCS10_Request::raw_public_key(), Botan::X509_Certificate::start_time(), Botan::PKCS10_Request::subject_public_key(), Botan::X509_Certificate::subject_public_key(), and Botan::X509_CRL::this_update().

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  }
MemoryVector< byte > Botan::Data_Store::get1_memvec ( const std::string &  key) const

Definition at line 103 of file datastor.cpp.

References Botan::hex_decode().

Referenced by Botan::X509_CRL::authority_key_id(), Botan::X509_Certificate::authority_key_id(), Botan::X509_Certificate::serial_number(), and Botan::X509_Certificate::subject_key_id().

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
u32bit Botan::Data_Store::get1_u32bit ( const std::string &  key,
u32bit  default_val = 0 
) const

Definition at line 120 of file datastor.cpp.

References Botan::to_u32bit().

Referenced by Botan::PKCS10_Request::constraints(), Botan::X509_Certificate::constraints(), Botan::X509_CRL::crl_number(), Botan::CRL_Entry::decode_from(), Botan::PKCS10_Request::is_CA(), Botan::X509_Certificate::is_CA_cert(), Botan::PKCS10_Request::path_limit(), Botan::X509_Certificate::path_limit(), and Botan::X509_Certificate::x509_version().

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
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  }
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  }
std::multimap< std::string, std::string > Botan::Data_Store::search_with ( const Matcher matcher) const

Definition at line 46 of file datastor.cpp.

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

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

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  }
void multimap_insert(std::multimap< K, V > &multimap, const K &key, const V &value)
Definition: stl_util.h:76

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