libDwmRDAP-0.1.4
Dwm::Ipv4CountryDb Class Reference

Encapsulates a database to map Ipv4Prefix to Ipv4CountryDbValue. More...

#include <DwmIpv4CountryDb.hh>

Inheritance diagram for Dwm::Ipv4CountryDb:
Collaboration diagram for Dwm::Ipv4CountryDb:

Public Member Functions

 Ipv4CountryDb (const std::string &fn="/usr/local/etc/ipv4country.db")
 Construct from the given filename fn. More...
 
bool Add (const RDAP::IPv4Response &rdapResponse)
 
bool Update (const RDAP::IPv4Response &rdapResponse)
 
bool Reload ()
 Reloads.
 
bool Save () const
 Saves the database.
 
void PrintJson (std::ostream &os) const
 Dump the database to an ostream in JSON form.
 
void CreateCountryAggregates ()
 
std::vector< Ipv4Prefix > PrefixesForCountries (const std::vector< std::string > &countries)
 
std::vector< Ipv4Prefix > PrefixesForCountries (const std::string &regExpression, bool minimalSet=true)
 
void AggregateAdjacents ()
 
- Public Member Functions inherited from Dwm::RDAP::Ipv4Routes< Ipv4CountryDbValue >
 Ipv4Routes ()
 Constructor.
 
void Clear ()
 Clears all entries.
 
bool Empty () const
 Returns true if there are no entries.
 
bool Add (const Ipv4Prefix &prefix, const Ipv4CountryDbValue &value)
 Adds an entry. More...
 
Ipv4CountryDbValueoperator[] (const Ipv4Prefix &prefix)
 operator [] works like you would expect from an STL map.
 
bool Delete (const Ipv4Prefix &prefix)
 Deletes the entry for prefix. More...
 
bool Find (const Ipv4Prefix &prefix, Ipv4CountryDbValue &match) const
 Find the entry for the given prefix. More...
 
bool Find (const Ipv4Address &ipAddr, std::vector< std::pair< Ipv4Prefix, Ipv4CountryDbValue > > &matches) const
 Finds all matches for ipAddr. More...
 
bool FindLongest (const Ipv4Address &ipAddr, std::pair< Ipv4Prefix, Ipv4CountryDbValue > &match) const
 Finds the longest match for ipAddr. More...
 
bool FindLongest (const Ipv4Address &ipAddr, std::pair< Ipv4Prefix, const Ipv4CountryDbValue * > &match) const
 Finds the longest match for ipAddr. More...
 
bool operator== (const Ipv4Routes< Ipv4CountryDbValue > &r) const
 operator == It's unlikely you'd ever need to use this, and it's expensive. More...
 
bool operator!= (const Ipv4Routes< Ipv4CountryDbValue > &r) const
 operator != It's unlikely you'd ever need to use this, and it's expensive. More...
 
uint32_t Size () const
 Returns the number of routes.
 
void HashSizes (std::vector< std::pair< uint8_t, uint32_t > > &sizes) const
 
uint32_t StreamedLength () const
 
std::istream & Read (std::istream &is)
 Reads the routes from an istream. Returns the istream.
 
size_t Read (FILE *f)
 Reades the routes from a FILE pointer. More...
 
ssize_t Read (int fd)
 Reads the routes from a file descriptor. More...
 
int Read (gzFile gzf)
 Reads the routes from a gzFile. More...
 
std::ostream & Write (std::ostream &os) const
 Writes the routes to an ostream. Returns the ostream.
 
size_t Write (FILE *f) const
 Writes the routes to a FILE pointer. More...
 
ssize_t Write (int fd) const
 Writes the routes to a file descriptor. More...
 
int Write (gzFile gzf) const
 Writes the routes to a gzFile. More...
 
int BZRead (BZFILE *bzf)
 Reads the routes from a BZFILE pointer. More...
 
int BZWrite (BZFILE *bzf) const
 Writes the routes to a BZFILE pointer. More...
 
void SortByKey (std::vector< std::pair< Ipv4Prefix, Ipv4CountryDbValue >> &target, bool ascending=true) const
 
void SortByValue (std::vector< std::pair< Ipv4Prefix, Ipv4CountryDbValue > > &target)
 Sorts the contained pair<Ipv4Prefix,_valueT> values into a vector, in descending order by the value stored for each prefix. More...
 
uint32_t AddressesCovered () const
 Returns the number of addresses covered by the contained prefixes, not including 0/0. More...
 

Additional Inherited Members

- Public Types inherited from Dwm::RDAP::Ipv4Routes< Ipv4CountryDbValue >
typedef std::map< Ipv4Address, Ipv4CountryDbValue_RepSubType
 
typedef _RepSubType::const_iterator const_iterator
 
- Protected Attributes inherited from Dwm::RDAP::Ipv4Routes< Ipv4CountryDbValue >
std::vector< _RepSubType > _maps
 
std::shared_mutex _mtx
 

Detailed Description

Encapsulates a database to map Ipv4Prefix to Ipv4CountryDbValue.

Constructor & Destructor Documentation

◆ Ipv4CountryDb()

Dwm::Ipv4CountryDb::Ipv4CountryDb ( const std::string &  fn = "/usr/local/etc/ipv4country.db")

Construct from the given filename fn.

Will load the contents of the file if possible.


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