32 #ifndef SECU_STRING_HPP
33 #define SECU_STRING_HPP
35 #include "../my_config.h"
85 bool operator != (
const std::string & ref)
const {
return ! (*
this == ref); };
86 bool operator != (
const secu_string & ref)
const {
return ! (*
this == ref); };
87 bool operator == (
const std::string &ref)
const {
return compare_with(ref.c_str(),(U_I)(ref.size())); };
88 bool operator == (
const secu_string &ref)
const {
return compare_with(ref.mem, *(ref.string_size)); };
100 void set(
int fd, U_I size);
111 void append_at(U_I offset,
const char *ptr, U_I size);
114 void append_at(U_I offset,
int fd, U_I size);
133 void resize(U_I size) { clean_and_destroy(); init(size); };
144 const char*
c_str()
const {
return mem ==
nullptr ?
throw SRC_BUG : mem; };
150 char operator[](U_I index)
const {
return (const_cast<secu_string *>(
this))->operator[](index); };
153 U_I
get_size()
const {
if(string_size ==
nullptr)
throw SRC_BUG;
return *string_size; };
165 bool compare_with(
const char *ptr, U_I size)
const;
166 void clean_and_destroy();
secu_string(const char *ptr, U_I size)
U_I get_allocated_size() const
get the size of the allocated secure space
are defined here basic integer types that tend to be portable
void append(const char *ptr, U_I size)
append some data at the end of the string
secu_string(const secu_string &ref)
the copy constructor
static bool is_string_secured()
secu_string & operator=(const secu_string &ref)
the assignment operator
~secu_string()
the destructor (set memory to zero before releasing it)
void reduce_string_size_to(U_I pos)
void clear()
clear the string (set to an empty string)
void set(int fd, U_I size)
exception used to signal a bug. A bug is triggered when reaching some code that should never be reach...
this is the base class of object that can be allocated on a memory pool
char & operator[](U_I index)
secu_string(U_I storage_size=0)
void append(int fd, U_I size)
append some data at the end of the string
U_I get_size() const
get the size of the string
void append_at(U_I offset, const char *ptr, U_I size)
const char * c_str() const
get access to the secure string
libdar namespace encapsulate all libdar symbols