Botan  1.11.15
Public Member Functions
Botan::Data_Store Class Reference

#include <datastor.h>

List of all members.

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 secure_vector< byte > &)
void add (const std::string &, const std::vector< byte > &)
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< 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_for (std::function< bool(std::string, std::string)> predicate) const

Detailed Description

Data Store

Definition at line 23 of file datastor.h.


Member Function Documentation

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

Definition at line 155 of file datastor.cpp.

Referenced by add().

   {
   std::multimap<std::string, std::string>::const_iterator i = in.begin();
   while(i != in.end())
      {
      contents.insert(*i);
      ++i;
      }
   }
void Botan::Data_Store::add ( const std::string &  key,
const std::string &  val 
)

Definition at line 126 of file datastor.cpp.

References Botan::multimap_insert().

   {
   multimap_insert(contents, key, val);
   }
void Botan::Data_Store::add ( const std::string &  key,
u32bit  val 
)

Definition at line 134 of file datastor.cpp.

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

   {
   add(key, std::to_string(val));
   }
void Botan::Data_Store::add ( const std::string &  key,
const secure_vector< byte > &  val 
)

Definition at line 142 of file datastor.cpp.

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

   {
   add(key, hex_encode(&val[0], val.size()));
   }
void Botan::Data_Store::add ( const std::string &  key,
const std::vector< byte > &  val 
)

Definition at line 147 of file datastor.cpp.

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

   {
   add(key, hex_encode(&val[0], val.size()));
   }
std::vector< std::string > Botan::Data_Store::get ( const std::string &  looking_for) const

Definition at line 50 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().

   {
   std::vector<std::string> out;
   auto range = contents.equal_range(looking_for);
   for(auto i = range.first; i != range.second; ++i)
      out.push_back(i->second);
   return out;
   }
std::string Botan::Data_Store::get1 ( const std::string &  key) const

Definition at line 62 of file datastor.cpp.

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

   {
   std::vector<std::string> vals = get(key);

   if(vals.empty())
      throw Invalid_State("Data_Store::get1: No values set for " + key);
   if(vals.size() > 1)
      throw Invalid_State("Data_Store::get1: More than one value for " + key);

   return vals[0];
   }
std::string Botan::Data_Store::get1 ( const std::string &  key,
const std::string &  default_value 
) const

Definition at line 74 of file datastor.cpp.

   {
   std::vector<std::string> vals = get(key);

   if(vals.size() > 1)
      throw Invalid_State("Data_Store::get1: More than one value for " + key);

   if(vals.empty())
      return default_value;

   return vals[0];
   }
std::vector< byte > Botan::Data_Store::get1_memvec ( const std::string &  key) const

Definition at line 92 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::raw_issuer_dn(), Botan::X509_Certificate::raw_subject_dn(), Botan::X509_Certificate::serial_number(), and Botan::X509_Certificate::subject_key_id().

   {
   std::vector<std::string> vals = get(key);

   if(vals.empty())
      return std::vector<byte>();

   if(vals.size() > 1)
      throw Invalid_State("Data_Store::get1_memvec: Multiple values for " +
                          key);

   return hex_decode(vals[0]);
   }
u32bit Botan::Data_Store::get1_u32bit ( const std::string &  key,
u32bit  default_val = 0 
) const

Definition at line 109 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().

   {
   std::vector<std::string> vals = get(key);

   if(vals.empty())
      return default_val;
   else if(vals.size() > 1)
      throw Invalid_State("Data_Store::get1_u32bit: Multiple values for " +
                          key);

   return to_u32bit(vals[0]);
   }
bool Botan::Data_Store::has_value ( const std::string &  key) const

Definition at line 27 of file datastor.cpp.

   {
   return (contents.lower_bound(key) != contents.end());
   }
bool Botan::Data_Store::operator== ( const Data_Store other) const

A search function

Definition at line 19 of file datastor.cpp.

   {
   return (contents == other.contents);
   }
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.

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

   {
   std::multimap<std::string, std::string> out;

   for(auto i = contents.begin(); i != contents.end(); ++i)
      if(predicate(i->first, i->second))
         out.insert(std::make_pair(i->first, i->second));

   return out;
   }

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