Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SoftwareAndServices::Library::Database::SQLCIDR Class Reference

An object that represents a network. More...

#include <SaS/Sql/SQLCIDR.hpp>

+ Inheritance diagram for SoftwareAndServices::Library::Database::SQLCIDR:
+ Collaboration diagram for SoftwareAndServices::Library::Database::SQLCIDR:

Public Member Functions

 SQLCIDR ()
 SQLCIDR - Default Constructor. More...
 
 SQLCIDR (const SQLCIDR &CopyFrom)
 SQLCIDR - Copy Constructor. More...
 
 SQLCIDR (const char *Val)
 SQLCDIR - Constructor. More...
 
 SQLCIDR (const char *Ip, uint16_t MaskBits)
 SQLCDIR - Constructor. More...
 
 SQLCIDR (in_addr &IpV4, uint8_t MaskBits)
 SQLCDIR - Constructor. More...
 
 SQLCIDR (in6_addr &IpV6, uint8_t MaskBits)
 SQLCDIR - Constructor. More...
 
virtual ~SQLCIDR ()
 SQLCIDR - Destructor. More...
 
std::vector< int32_t > * Array () const
 Get the array information. More...
 
const char * ArraySpecs (const char *Format=NULL) const
 Print the array specifications, or NONE when they do not exist. More...
 
void Attributes (SqlColumnAttributes *Attrs)
 Set the column attributes. More...
 
virtual const char * BaseType () const
 Get the C++ base type name. More...
 
virtual DataTypeBaseCopy () const
 Copy this object. More...
 
virtual InstanceCount_t decInstance () const
 Decrement the instance. More...
 
bool Default (const char *&DefVal) const
 Get its default value as a (char*). More...
 
bool Default (long double &DefVal) const
 Get its default value as a (long double). More...
 
bool Default (bool &DefVal) const
 Get its default value as a (bool). More...
 
void Dim (uint32_t Dim, int32_t DimSize)
 Set the maximum dimension (may grow). More...
 
SqlColumnForeignKeyForeignKey () const
 
void ForeignKey (SqlColumnForeignKey *Fk)
 Set any ForeignKey data for this column. More...
 
virtual bool fromString (const char *TheValue)
 Convert the object value from a string. More...
 
bool fromString (const String &TheValue)
 Convert the object value from a string. More...
 
bool fromString (const std::string &TheValue)
 Convert the object value from a string. More...
 
bool Get (in_addr &Ipv4Address, uint8_t &Mask) const
 Get the IPv4 address and mask if an IPv4 address. More...
 
bool Get (in6_addr &Ipv6Address, uint16_t &Mask) const
 Set the IPv6 address and mask if an IPv6 address. More...
 
virtual InstanceCount_t getInstance () const
 
bool HasDefault () const
 Determine if this column has any default value. More...
 
bool HasForeignKey () const
 
bool HasSequence () const
 
virtual InstanceCount_t incInstance () const
 Increment the instance. More...
 
bool IsIpV4 () const
 Determine if this address is an IPv4 address. More...
 
bool IsIpV6 () const
 Determine if this address is an IPv6 address. More...
 
bool IsNull () const
 
bool IsPrimary () const
 
void IsPrimary (bool SetPrimary)
 Set if this column is the primary key for the table. More...
 
void IsSequence (bool SetSeq, const char *SeqName)
 Set if this column is an auto-increment value. More...
 
bool IsSequence (const char *&SeqName) const
 
bool IsUnique () const
 
void IsUnique (bool SetUnique)
 Set if this column data is unique in the table. More...
 
void Length (uint64_t Len)
 Set the length of the data. More...
 
uint64_t Length () const
 
bool MayBeNull () const
 
void MayBeNull (bool SetNullOk)
 Set if this column may be set to null. More...
 
void Name (const char *NewName)
 Set the name of the column. More...
 
const char * Name () const
 
void operator delete (void *ToFree)
 
bool operator!= (const SQLCIDR &CompareTo) const
 Compare this object to CompareTo. More...
 
bool operator!= (const SqlColumn &Other)
 Compare Operator. More...
 
SQLCIDRoperator= (const SQLCIDR &CopyFrom)
 Copy the cidrs, return (*this) updated. More...
 
bool operator== (const SQLCIDR &CompareTo) const
 Compare this object to CompareTo. More...
 
bool operator== (const SqlColumn &Other)
 Compare Operator. More...
 
void Set (in_addr &Ipv4Address, uint8_t Mask)
 Set the IPv4 address and mask if an IPv4 address. More...
 
void Set (in6_addr &Ipv6Address, uint16_t Mask)
 Get the IPv6 address and mask if an IPv6 address. More...
 
virtual const char * toString () const
 Convert the object value to a string. More...
 
SQL::SqlDataType_e Type () const
 
void Type (SQL::SqlDataType_e Dt)
 Set the SqlDataType_e for this object. More...
 

Static Public Member Functions

static void CreateCpp ()
 Create the C++ code for all SQL FUNCTION objects. More...
 
static void FromVector (std::vector< SQLCIDR *> &Vector, String &Results)
 Convert an array of values, into a form suitable for an insert. More...
 
static bool GenExtractUtcTime_t (const char *ColName, String &Results)
 Generate an SQL statement that will extract a TIMESTAMP to UTC, as a time_t value as a (char*). More...
 
static bool ToSqlTime (time_t TheTimeT, String &Results)
 Convert a time_t in UTC, to a value acceptable to SQL as a timestamp. More...
 
static void ToVector (const char *OneString, std::vector< SQLCIDR *> &Results)
 Convert an SQL array result to an array of SqlColumn values. More...
 

Protected Member Functions

void CopyColumnData (const SqlColumn &Other)
 Copy just the SqlColumn Data only. More...
 

Protected Attributes

std::vector< int32_t > * _ArrayInfo
 When an array, this pointer will be NON-NULL. More...
 
SQL::SqlDataType_e _Dt
 The data type. More...
 
char * _ToStringCache
 When non-NULL, the object value as a (char*). More...
 

Detailed Description

An object that represents a network.

Address and maskbits.

When the mask for an IPv4 address is 32, the it represents a single host.

When the mask for an IPv4 address is 128, the it represents a single host.

Definition at line 58 of file SQLCIDR.hpp.

Constructor & Destructor Documentation

◆ SQLCIDR() [1/6]

SoftwareAndServices::Library::Database::SQLCIDR::SQLCIDR ( )

SQLCIDR - Default Constructor.

◆ SQLCIDR() [2/6]

SoftwareAndServices::Library::Database::SQLCIDR::SQLCIDR ( const SQLCIDR CopyFrom)

SQLCIDR - Copy Constructor.

Parameters
CopyFromThe SQLCIDR object to copy from.

◆ SQLCIDR() [3/6]

SoftwareAndServices::Library::Database::SQLCIDR::SQLCIDR ( const char *  Val)

SQLCDIR - Constructor.

Parameters
ValThe value as a dotted IPv4 address (192.168.100.128), An IPv4 address with mask bits (192.168.100.128/25), a colon IPv6 address (2001:4f8:3:ba:2e0:81ff:fe22:d1f1), a colon IPv6 address with mask bits (2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128)

◆ SQLCIDR() [4/6]

SoftwareAndServices::Library::Database::SQLCIDR::SQLCIDR ( const char *  Ip,
uint16_t  MaskBits 
)

SQLCDIR - Constructor.

Parameters
IpAn IPv4 or IPv6 address The value as a dotted IPv4 address (192.168.100.128), a colon IPv6 address (2001:4f8:3:ba:2e0:81ff:fe22:d1f1).
MaskBitsThe number of bits in the mask. 0-32 for IPv4, or 0-128 for IPv6.

◆ SQLCIDR() [5/6]

SoftwareAndServices::Library::Database::SQLCIDR::SQLCIDR ( in_addr &  IpV4,
uint8_t  MaskBits 
)

SQLCDIR - Constructor.

Parameters
IpV4An IPv4 address.
MaskBitsThe number of bits in the mask, 0-32.

◆ SQLCIDR() [6/6]

SoftwareAndServices::Library::Database::SQLCIDR::SQLCIDR ( in6_addr &  IpV6,
uint8_t  MaskBits 
)

SQLCDIR - Constructor.

Parameters
IpV6An IPv6 address.
MaskBitsThe number of bits in the mask, 0-128.

◆ ~SQLCIDR()

virtual SoftwareAndServices::Library::Database::SQLCIDR::~SQLCIDR ( )
virtual

SQLCIDR - Destructor.

Member Function Documentation

◆ Array()

std::vector<int32_t>* SoftwareAndServices::Library::Database::DataTypeBase::Array ( ) const
inherited

Get the array information.

Returns
The array information, or NULL when NOT an array.

◆ ArraySpecs()

const char* SoftwareAndServices::Library::Database::DataTypeBase::ArraySpecs ( const char *  Format = NULL) const
inherited

Print the array specifications, or NONE when they do not exist.

([][], [3][10], ...)

Parameters
FormatWhen non-NULL, format using snprintf. When non-NULL a single 's' will be replaced with the results.

Example, Called with "SQLBIGINTs' could return with: SQLBIGINT[][], SQLBIGINT[3][10], or when there are no dimensions SQLBIGINT.

Note
The results are overwritten on each call.
Returns
The array specification optionally formatted with Format.

◆ Attributes()

void SoftwareAndServices::Library::Database::SqlColumn::Attributes ( SqlColumnAttributes Attrs)
inherited

Set the column attributes.

Used by YACC to set what it found.

Parameters
AttrsThe attributes.

◆ BaseType()

virtual const char* SoftwareAndServices::Library::Database::SQLCIDR::BaseType ( ) const
virtual

Get the C++ base type name.

(int32_t, SQLTIMESTAMP, double, (char*), ...)

Implements SoftwareAndServices::Library::Database::DataTypeBase.

◆ Copy()

virtual DataTypeBase* SoftwareAndServices::Library::Database::SQLCIDR::Copy ( ) const
virtual

Copy this object.

Returns
A new copy of this object.

Implements SoftwareAndServices::Library::Database::DataTypeBase.

◆ CopyColumnData()

void SoftwareAndServices::Library::Database::SqlColumn::CopyColumnData ( const SqlColumn Other)
protectedinherited

Copy just the SqlColumn Data only.

Used by the derived clases Copy() method.

Parameters
OtherThe other SqlColumn to copy from.

◆ CreateCpp()

static void SoftwareAndServices::Library::Database::SqlColumn::CreateCpp ( )
staticinherited

Create the C++ code for all SQL FUNCTION objects.

◆ decInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< DataTypeBase >::decInstance ( ) const
inlinevirtualinherited

Decrement the instance.

Returns
The instance count, after decrementing it.

Definition at line 129 of file instance.hpp.

◆ Default() [1/3]

bool SoftwareAndServices::Library::Database::SqlColumn::Default ( const char *&  DefVal) const
inherited

Get its default value as a (char*).

Parameters
[out]DefValThe default value as a (char*).
Returns
true when this column has a string default value.

◆ Default() [2/3]

bool SoftwareAndServices::Library::Database::SqlColumn::Default ( long double &  DefVal) const
inherited

Get its default value as a (long double).

Parameters
[out]DefValThe default value as a double.
Returns
true when this column has a double default value.

◆ Default() [3/3]

bool SoftwareAndServices::Library::Database::SqlColumn::Default ( bool &  DefVal) const
inherited

Get its default value as a (bool).

Parameters
[out]DefValThe default value as a bool.
Returns
true when this column has a boolean default value.

◆ Dim()

void SoftwareAndServices::Library::Database::DataTypeBase::Dim ( uint32_t  Dim,
int32_t  DimSize 
)
inherited

Set the maximum dimension (may grow).

Parameters
DimNumberThe number of dimensions. When DimNumber is greater than the current number of dimensions, it is incremented. When less, only the size is set.
DimSizeThe size of dimension DimNumber.

◆ ForeignKey() [1/2]

SqlColumnForeignKey* SoftwareAndServices::Library::Database::SqlColumn::ForeignKey ( ) const
inherited
Returns
any ForeignKey data, or NULL when none.

◆ ForeignKey() [2/2]

void SoftwareAndServices::Library::Database::SqlColumn::ForeignKey ( SqlColumnForeignKey Fk)
inherited

Set any ForeignKey data for this column.

Parameters
FkThe foreign key data.

◆ fromString() [1/3]

virtual bool SoftwareAndServices::Library::Database::SQLCIDR::fromString ( const char *  TheValue)
virtual

Convert the object value from a string.

Parameters
TheValueThe value to convert to the data type.

Implements SoftwareAndServices::Library::Database::DataTypeBase.

◆ fromString() [2/3]

bool SoftwareAndServices::Library::Database::DataTypeBase::fromString ( const String TheValue)
inherited

Convert the object value from a string.

Parameters
TheValueThe value to convert to the data type.

◆ fromString() [3/3]

bool SoftwareAndServices::Library::Database::DataTypeBase::fromString ( const std::string &  TheValue)
inherited

Convert the object value from a string.

Parameters
TheValueThe value to convert to the data type.

◆ FromVector()

static void SoftwareAndServices::Library::Database::SQLCIDR::FromVector ( std::vector< SQLCIDR *> &  Vector,
String &  Results 
)
static

Convert an array of values, into a form suitable for an insert.

Parameters
VectorThe array of values to convert to a SQL INSERT string.
[out]ResultsWhere the results are stored.

◆ GenExtractUtcTime_t()

static bool SoftwareAndServices::Library::Database::DataTypeBase::GenExtractUtcTime_t ( const char *  ColName,
String Results 
)
staticinherited

Generate an SQL statement that will extract a TIMESTAMP to UTC, as a time_t value as a (char*).

This does not fetch the column value, it generates the SQL SELECT string.

Called with ColName set to created, it will produce the string:

extract(epoch from created at time zone utc)

The results can be used in place of a column name in a SQL SELECT command.

Parameters
ColNameThe SQL table column name.
[out]ResultsWhere the results will be stored. The results will be appended to any existing value in Results.
Returns
true on success.

◆ Get() [1/2]

bool SoftwareAndServices::Library::Database::SQLCIDR::Get ( in_addr &  Ipv4Address,
uint8_t &  Mask 
) const

Get the IPv4 address and mask if an IPv4 address.

Parameters
Ipv4AddressWhen the results are true, this IPv4 address.
MaskWhen the results are true, the IPv4 mask.
Returns
true if this object is an IPv4 address and the Ipv4Address and Mask are filled in. Returns false if not an IPv4 address, or has not been set.

◆ Get() [2/2]

bool SoftwareAndServices::Library::Database::SQLCIDR::Get ( in6_addr &  Ipv6Address,
uint16_t &  Mask 
) const

Set the IPv6 address and mask if an IPv6 address.

Parameters
Ipv6AddressWhen the results are true, this IPv6 address.
MaskWhen the results are true, the IPv6 mask. Returns false if not an IPv6 address, or has not been set.

◆ getInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< DataTypeBase >::getInstance ( ) const
inlinevirtualinherited
Returns
The current instance count.

Definition at line 118 of file instance.hpp.

◆ HasDefault()

bool SoftwareAndServices::Library::Database::SqlColumn::HasDefault ( ) const
inherited

Determine if this column has any default value.

◆ HasForeignKey()

bool SoftwareAndServices::Library::Database::SqlColumn::HasForeignKey ( ) const
inherited
Returns
true when this object has a foreign key.

◆ HasSequence()

bool SoftwareAndServices::Library::Database::SqlColumn::HasSequence ( ) const
inherited
Returns
true when this column is a auto increment type.

◆ incInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< DataTypeBase >::incInstance ( ) const
inlinevirtualinherited

Increment the instance.

Returns
The instance value, after incrementing it.

Definition at line 109 of file instance.hpp.

◆ IsIpV4()

bool SoftwareAndServices::Library::Database::SQLCIDR::IsIpV4 ( ) const

Determine if this address is an IPv4 address.

Returns
true if an IPv4 address. If not set, will return false.

◆ IsIpV6()

bool SoftwareAndServices::Library::Database::SQLCIDR::IsIpV6 ( ) const

Determine if this address is an IPv6 address.

Returns
true if an IPv6 address. If not set, will return false.

◆ IsNull()

bool SoftwareAndServices::Library::Database::SqlColumn::IsNull ( ) const
inherited
Returns
true when this columns value is null.

◆ IsPrimary() [1/2]

bool SoftwareAndServices::Library::Database::SqlColumn::IsPrimary ( ) const
inherited
Returns
true when this columb is the primary key for the table.

◆ IsPrimary() [2/2]

void SoftwareAndServices::Library::Database::SqlColumn::IsPrimary ( bool  SetPrimary)
inherited

Set if this column is the primary key for the table.

Parameters
SetPrimaryWhen true, this columb is the primary key for the table.

◆ IsSequence() [1/2]

void SoftwareAndServices::Library::Database::SqlColumn::IsSequence ( bool  SetSeq,
const char *  SeqName 
)
inherited

Set if this column is an auto-increment value.

Parameters
SetSeqWhen true, this column value is an auto increment value.
SeqNameOptional, some SQL databases name the sequence.

◆ IsSequence() [2/2]

bool SoftwareAndServices::Library::Database::SqlColumn::IsSequence ( const char *&  SeqName) const
inherited
Parameters
[out]SeqNameA (char*) that will be updated when the sequence has a name.
Returns
true when this column's value is auto increment. Will be set to NULL when the sequence does not have a name.

◆ IsUnique() [1/2]

bool SoftwareAndServices::Library::Database::SqlColumn::IsUnique ( ) const
inherited
Returns
true if this column value is unique in the table.

◆ IsUnique() [2/2]

void SoftwareAndServices::Library::Database::SqlColumn::IsUnique ( bool  SetUnique)
inherited

Set if this column data is unique in the table.

SetUnique When true, the column value is unique in the table.

◆ Length() [1/2]

void SoftwareAndServices::Library::Database::SqlColumn::Length ( uint64_t  Len)
inherited

Set the length of the data.

Parameters
LenThe length, or zero (0) for unspecified.

◆ Length() [2/2]

uint64_t SoftwareAndServices::Library::Database::SqlColumn::Length ( ) const
inherited
Returns
the length of the data, or zero (0) for unspecified.

◆ MayBeNull() [1/2]

bool SoftwareAndServices::Library::Database::SqlColumn::MayBeNull ( ) const
inherited
Returns
true when this column may be set to null.

◆ MayBeNull() [2/2]

void SoftwareAndServices::Library::Database::SqlColumn::MayBeNull ( bool  SetNullOk)
inherited

Set if this column may be set to null.

Parameters
SetNullOkWhen true, this columns value may be set to null.

◆ Name() [1/2]

void SoftwareAndServices::Library::Database::SqlColumn::Name ( const char *  NewName)
inherited

Set the name of the column.

Parameters
NewNamethe name of the column.

◆ Name() [2/2]

const char* SoftwareAndServices::Library::Database::SqlColumn::Name ( ) const
inherited
Returns
the name of the column, or NULL if not yet set.

◆ operator!=() [1/2]

bool SoftwareAndServices::Library::Database::SQLCIDR::operator!= ( const SQLCIDR CompareTo) const

Compare this object to CompareTo.

Parameters
CompareToThe SQLCIDR obejct to compare to.
Returns
true when they are not the same.

◆ operator!=() [2/2]

bool SoftwareAndServices::Library::Database::SqlColumn::operator!= ( const SqlColumn Other)
inherited

Compare Operator.

Parameters
OtherThe other object to compare to.
Returns
true when they do not have the same values.

◆ operator=()

SQLCIDR& SoftwareAndServices::Library::Database::SQLCIDR::operator= ( const SQLCIDR CopyFrom)

Copy the cidrs, return (*this) updated.

Parameters
CopyFromthe SQLCIDR object to copy from.
Returns
(*this) updated from CopyFrom.

◆ operator==() [1/2]

bool SoftwareAndServices::Library::Database::SQLCIDR::operator== ( const SQLCIDR CompareTo) const

Compare this object to CompareTo.

Parameters
CompareToThe SQLCIDR obejct to compare to.
Returns
true when they are the same.

◆ operator==() [2/2]

bool SoftwareAndServices::Library::Database::SqlColumn::operator== ( const SqlColumn Other)
inherited

Compare Operator.

Parameters
OtherThe other object to compare to.
Returns
true when they have the same values.

◆ Set() [1/2]

void SoftwareAndServices::Library::Database::SQLCIDR::Set ( in_addr &  Ipv4Address,
uint8_t  Mask 
)

Set the IPv4 address and mask if an IPv4 address.

Parameters
Ipv4AddressWhen the results are true, this IPv4 address.
MaskWhen the results are true, the IPv4 mask.

◆ Set() [2/2]

void SoftwareAndServices::Library::Database::SQLCIDR::Set ( in6_addr &  Ipv6Address,
uint16_t  Mask 
)

Get the IPv6 address and mask if an IPv6 address.

Parameters
Ipv6AddressWhen the results are true, this IPv6 address.
MaskWhen the results are true, the IPv6 mask.

◆ ToSqlTime()

static bool SoftwareAndServices::Library::Database::DataTypeBase::ToSqlTime ( time_t  TheTimeT,
String Results 
)
staticinherited

Convert a time_t in UTC, to a value acceptable to SQL as a timestamp.

Parameters
TheTimeTThe time_t value.
ResultsWhere the results will be appended.
Returns
true if converted.

◆ toString()

virtual const char* SoftwareAndServices::Library::Database::SQLCIDR::toString ( ) const
virtual

Convert the object value to a string.

Implements SoftwareAndServices::Library::Database::DataTypeBase.

◆ ToVector()

static void SoftwareAndServices::Library::Database::SQLCIDR::ToVector ( const char *  OneString,
std::vector< SQLCIDR *> &  Results 
)
static

Convert an SQL array result to an array of SqlColumn values.

Example: A PostgreSQL table column is an array of integer (measured integer[]). It is returned from a SELECT as: "{1, 5, 7}"

This method converts the SELECT results into separate (SQLINTEGER*) values.

Parameters
OneStringThe string returned from SELECT.
[out]ResultsWere the results will be stored. The contents of Results will be cleared before filling in the results.

◆ Type() [1/2]

SQL::SqlDataType_e SoftwareAndServices::Library::Database::DataTypeBase::Type ( ) const
inherited
Returns
the SqlDataType_e for this object.

◆ Type() [2/2]

void SoftwareAndServices::Library::Database::DataTypeBase::Type ( SQL::SqlDataType_e  Dt)
inherited

Set the SqlDataType_e for this object.

Parameters
DtThe data type.

Member Data Documentation

◆ _ArrayInfo

std::vector<int32_t>* SoftwareAndServices::Library::Database::DataTypeBase::_ArrayInfo
protectedinherited

When an array, this pointer will be NON-NULL.

Definition at line 1968 of file SQL.hpp.

◆ _Dt

SQL::SqlDataType_e SoftwareAndServices::Library::Database::DataTypeBase::_Dt
protectedinherited

The data type.

Definition at line 1963 of file SQL.hpp.

◆ _ToStringCache

char* SoftwareAndServices::Library::Database::DataTypeBase::_ToStringCache
mutableprotectedinherited

When non-NULL, the object value as a (char*).

Definition at line 1973 of file SQL.hpp.


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