Protocol++® (Protocolpp®)  v5.6.2
ProtocolPP::jarray< T > Class Template Reference

Public Member Functions

 jarray ()
 Standard constructor for jarray class.
 
 jarray (uint32_t size)
 
 jarray (std::initializer_list< T > init)
 
 jarray (uint32_t size, T value, endian_t format=BIG)
 
 jarray (const jarray< T > &rhs, endian_t format=BIG)
 
 jarray (const std::string &rhs, endian_t format=BIG, bool encoded=false)
 
 jarray (const std::vector< T > &rhs, endian_t format=BIG)
 
 jarray (const T *rhs, uint32_t size, endian_t format=BIG)
 
 jarray (const std::shared_ptr< jarray< T >> &rhs, endian_t format=BIG)
 
template<typename TT >
 jarray (jarray< TT > &rhs, endian_t format=BIG)
 
 ~jarray ()=default
 Standard deconstructor for jarray.
 
uint32_t get_size ()
 
bool empty ()
 
jarray< T > split (uint32_t elements)
 
jarray< T > extract (uint32_t index, uint32_t elements)
 
void push_back (T rhs)
 
void pop_back ()
 
void resize (uint32_t newsize)
 
void append (jarray< T > rhs)
 
void append (T *rhs, uint32_t rhs_size)
 
void append (std::initializer_list< T > rhs)
 
void insert (uint32_t index, jarray< T > &rhs)
 
void update (uint32_t index, jarray< T > &rhs)
 
void erase (uint32_t index, uint32_t elements)
 
void intersect (jarray< T > &rhs)
 
void reverse ()
 Method to reverse the elements of the array.
 
T * get_ptr ()
 
const T * get_ptr () const
 
std::shared_ptr< jarray< T > > get_shared ()
 
const std::shared_ptr< jarray< T > > get_shared () const
 
std::string to_string (bool printable=false, int indent=10, bool xml=false)
 
std::string debug (jarray< T > &expect, int indent=10)
 
bool operator== (jarray< T > &rhs)
 
bool operator== (const jarray< T > &rhs) const
 
bool operator!= (jarray< T > &rhs)
 
bool operator!= (const jarray< T > &rhs) const
 
void operator^= (jarray< T > &rhs)
 
void operator|= (jarray< T > &rhs)
 
void operator&= (jarray< T > &rhs)
 
void operator*= (jarray< T > &rhs)
 
void operator+= (jarray< T > &rhs)
 
T & operator[] (uint32_t index)
 
const T & operator[] (uint32_t index) const
 
endian_t get_format ()
 
void serase ()
 Method to scrub array in memory.
 

Constructor & Destructor Documentation

◆ jarray() [1/9]

template<typename T >
jarray::jarray ( uint32_t  size)
explicit

Constructor for jarray initialized to size

Parameters
size- size to initialize the array to

◆ jarray() [2/9]

template<typename T >
jarray::jarray ( std::initializer_list< T >  init)

Constructor for jarray initialized to size with value

Parameters
init- initializer list in curly braces myarr<uint8_t> {0x10, 0x1E};

◆ jarray() [3/9]

template<typename T >
jarray::jarray ( uint32_t  size,
value,
endian_t  format = BIG 
)

Constructor for jarray initialized to size with value

Parameters
size- size to initialize the array to
value- value to initialize the array to
format- endianness of the constructed array (BIG, LITTLE)

◆ jarray() [4/9]

template<typename T >
jarray::jarray ( const jarray< T > &  rhs,
endian_t  format = BIG 
)

Copy Constructor for jarray

Parameters
rhs- array to copy
format- endianness of the constructed array (BIG, LITTLE)

◆ jarray() [5/9]

template<typename T >
jarray::jarray ( const std::string &  rhs,
endian_t  format = BIG,
bool  encoded = false 
)
explicit

Constructor for jarray from a string

Parameters
rhs- string to populate the array with
format- endianness of the constructed array (BIG, LITTLE)
encoded- Input string has already been encoded as HEX characters instead of being a simple string. For example, if the input string had been encoded as bytes each character in the string would be equal to something like '0x6C' or '0xAE'. If the input was a simple string each character would represent a single value such that the string "123ABC" is really "1", "2" "3", "A", "B", "C" and needs to be converted and grouped into HEX such that the resulting array has "0x12", "0x3A", and "0xBC". The Crypto++ library uses encoded strings. Set encoded to true to read in ASCII characters
Here is the call graph for this function:

◆ jarray() [6/9]

template<typename T >
jarray::jarray ( const std::vector< T > &  rhs,
endian_t  format = BIG 
)
explicit

Constructor for jarray from a standard vector

Parameters
rhs- vector to initialize the array with
format- endianness of the constructed array (BIG, LITTLE)

◆ jarray() [7/9]

template<typename T >
jarray::jarray ( const T *  rhs,
uint32_t  size,
endian_t  format = BIG 
)

Constructor for jarray from a uint8_t raw pointer and size

Parameters
rhs- byte pointer to initialize the array with
size- length of the data to convert
format- endianness of the constructed array (BIG, LITTLE)

◆ jarray() [8/9]

template<typename T >
jarray::jarray ( const std::shared_ptr< jarray< T >> &  rhs,
endian_t  format = BIG 
)
explicit

Constructor for jarray from a shared pointer

Parameters
rhs- byte pointer to initialize the array with
format- endianness of the constructed array (BIG, LITTLE)

◆ jarray() [9/9]

template<typename T >
template<typename TT >
jarray::jarray ( jarray< TT > &  rhs,
endian_t  format = BIG 
)
explicit

Constructor for jarray from one type to another

Parameters
rhs- initial array to convert. Conversion is to type of array that is being constructed. Example:
jarray<uint32_t> oldarray("AABBCCDD");
jarray<uint8_t> newarray(oldarray, LITTLE);
newarray.to_sting();
"DDCCBBAA"
@ LITTLE
Little endian with formatting as b[0]b[1]b[2]b[3].
Definition: jenum.h:1212
format- endianness of the constructed array (BIG, LITTLE)
Here is the call graph for this function:

Member Function Documentation

◆ append() [1/3]

template<typename T >
void jarray::append ( jarray< T >  rhs)

Method to add the array rhs to the current array

Parameters
rhs- array to add to this array
Here is the call graph for this function:

◆ append() [2/3]

template<typename T >
void jarray::append ( std::initializer_list< T >  rhs)

Method to add the array rhs to the current array

Parameters
rhs- initializer list to add to this array

◆ append() [3/3]

template<typename T >
void jarray::append ( T *  rhs,
uint32_t  rhs_size 
)

Method to add the array rhs to the current array

Parameters
rhs- pointer to array to add to this array
rhs_size- length of the array pointed to by rhs

◆ debug()

template<typename T >
std::string jarray::debug ( jarray< T > &  expect,
int  indent = 10 
)

Method to compare arrays side by side for debug as shown below prints to std::err

AAAABBBB_CCCCDDDD_EEEEFFFF_00001111 AAAABBBB_CCCCDDDD_EEEEFFFF_00001111
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_FE889999 <-- MISMATCH
22223333_44445555_66667777_88889999 22223333_44445555_66667777_88889999
Parameters
expect- Expected data to print
indent- default indentation for pretty printing
Returns
string representation of this array
Here is the call graph for this function:

◆ empty()

template<typename T >
bool jarray::empty

Method to determine if the array is empty

Returns
True/False if araay is empty

◆ erase()

template<typename T >
void jarray::erase ( uint32_t  index,
uint32_t  elements 
)

Method to remove the elements from the array starting at index and continuing for size. The original array is reduced by the number of elements requested

Parameters
index- location to start erasing elements
elements- number of elements to remove from this array

◆ extract()

template<typename T >
jarray< T > jarray::extract ( uint32_t  index,
uint32_t  elements 
)

Method to extract the number of elements from the array starting at the start value

Parameters
index- index to start the extraction
elements- number of elements to split from the array
Returns
new array containing the split off values

◆ get_format()

template<typename T >
endian_t jarray::get_format

Method to return endianness format of this array

Returns
endianness format for this array

◆ get_ptr() [1/2]

template<typename T >
T * jarray::get_ptr

Method to return the pointer to the underlying data object of the array

Returns
pointer to the data object

◆ get_ptr() [2/2]

template<typename T >
const T * jarray::get_ptr

Method to return the pointer to the underlying data object of the array

Returns
pointer to the data object

◆ get_shared() [1/2]

template<typename T >
std::shared_ptr< jarray< T > > jarray::get_shared

Method to return the shared pointer of the array

Returns
shared pointer to the data object

◆ get_shared() [2/2]

template<typename T >
const std::shared_ptr< jarray< T > > jarray::get_shared

Method to return the shared pointer of the array

Returns
shared pointer to the data object

◆ get_size()

template<typename T >
uint32_t jarray::get_size

Method to retrieve size of this array

Returns
Size of the array

◆ insert()

template<typename T >
void jarray::insert ( uint32_t  index,
jarray< T > &  rhs 
)

Method to insert the array rhs into this array starting at index The array is resized to accomodate this array plus the new array No elements of the original array are overwritten

Parameters
index- location to start the insertion
rhs- array to insert into this array
Here is the call graph for this function:

◆ intersect()

template<typename T >
void jarray::intersect ( jarray< T > &  rhs)

Method to intersect two arrays and return the shared valeus in both arrays

Parameters
rhs- array to intersect with this array (retains shared values)
Here is the call graph for this function:

◆ operator!=() [1/2]

template<typename T >
bool jarray::operator!= ( const jarray< T > &  rhs) const

Method to compare two different arrays. First compares array size then iterates through all array values and compares them for inequality

Parameters
rhs- array to compare with this array
Returns
true/false value for array comparison

◆ operator!=() [2/2]

template<typename T >
bool jarray::operator!= ( jarray< T > &  rhs)

Method to compare two different arrays. First compares array size then iterates through all array values and compares them for inequality

Parameters
rhs- array to compare with this array
Returns
true/false value for array comparison

◆ operator&=()

template<typename T >
void jarray::operator&= ( jarray< T > &  rhs)

Method to AND two different arrays

Parameters
rhs- array to AND with this array
Here is the call graph for this function:

◆ operator*=()

template<typename T >
void jarray::operator*= ( jarray< T > &  rhs)

Method to MULTIPLY two different arrays

Parameters
rhs- array to MULTIPLY with this array
Here is the call graph for this function:

◆ operator+=()

template<typename T >
void jarray::operator+= ( jarray< T > &  rhs)

Method to ADD two different arrays

Parameters
rhs- array to ADD with this array
Here is the call graph for this function:

◆ operator==() [1/2]

template<typename T >
bool jarray::operator== ( const jarray< T > &  rhs) const

Method to compare two different arrays. First compares array size then iterates through all array values and compares them for equality

Parameters
rhs- array to compare with this array
Returns
true/false value for array comparison
Here is the call graph for this function:

◆ operator==() [2/2]

template<typename T >
bool jarray::operator== ( jarray< T > &  rhs)

Method to compare two different arrays. First compares array size then iterates through all array values and compares them for equality

Parameters
rhs- array to compare with this array
Returns
true/false value for array comparison
Here is the call graph for this function:

◆ operator[]() [1/2]

template<typename T >
T & jarray::operator[] ( uint32_t  index)

Method to return array value at index

Parameters
index- location of array element to return
Returns
array element at index

◆ operator[]() [2/2]

template<typename T >
const T & jarray::operator[] ( uint32_t  index) const

Method to return const array value at index

Parameters
index- location of array element to return
Returns
const array element at index

◆ operator^=()

template<typename T >
void jarray::operator^= ( jarray< T > &  rhs)

Method to XOR two different arrays

Parameters
rhs- array to XOR with this array
Here is the call graph for this function:

◆ operator|=()

template<typename T >
void jarray::operator|= ( jarray< T > &  rhs)

Method to OR two different arrays

Parameters
rhs- array to OR with this array
Here is the call graph for this function:

◆ pop_back()

template<typename T >
void jarray::pop_back

Method to removed the last element from the array. The element is destroyed in the process

◆ push_back()

template<typename T >
void jarray::push_back ( rhs)

Method to add a single element to the end of the array

Parameters
rhs- element to add to this array

◆ resize()

template<typename T >
void jarray::resize ( uint32_t  newsize)

Method to change the array size

Parameters
newsize- either shrink or expand the array to the new size

◆ split()

template<typename T >
jarray< T > jarray::split ( uint32_t  elements)

Method to split the number of elements from the front of the array and return it to the caller. The original array is reduced by the number of elements split from it

Parameters
elements- number of elements to split from the array
Returns
new array containing the split off values
Here is the call graph for this function:

◆ to_string()

template<typename T >
std::string jarray::to_string ( bool  printable = false,
int  indent = 10,
bool  xml = false 
)

Method to convert this array into a string representation for printing purposes. Output is formatted either as a single, long string of HEX characters if 'printable' is false or is a pretty printed 16-bytes across with underscores as follows if 'printable' is true

[AAAABBBB_CCCCDDDD_EEEEFFFF_00001111
22223333_44445555_66667777_88889999
22223333_44445555_66667777_88889999
22223333_44445555_66667777_88889999
22223333_44445555_66667777_88889999
22223333_44445555_66667777_88889999
22223333_44445555_66667777_88889999]
Parameters
printable- if false, output is a single string of HEX characters. If true, enables pretty_printing of the array with formatting
indent- default indentation for pretty printing ignored if printable is false
xml- Print as an XML data object as found below
*  22223333444455556666777788889999
*  2222333344445555666677778888
* 
Returns
string representation of this array
Here is the call graph for this function:

◆ update()

template<typename T >
void jarray::update ( uint32_t  index,
jarray< T > &  rhs 
)

Method to update the array rhs into this array starting at index The array is resized to accomodate this array plus the new array Elements of the original array starting at index and extending for the length of rhs are overwritten with the new values

Parameters
index- location to start the update
rhs- array to update this array with
Here is the call graph for this function:

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