 |
Disk ARchive
2.6.8
Full featured and portable backup and archiving tool
|
Go to the documentation of this file.
32 #ifndef SECU_STRING_HPP
33 #define SECU_STRING_HPP
35 #include "../my_config.h"
95 bool operator != (
const std::string & ref)
const {
return ! (*
this == ref); };
96 bool operator != (
const secu_string & ref)
const {
return ! (*
this == ref); };
97 bool operator == (
const std::string &ref)
const {
return compare_with(ref.c_str(),(U_I)(ref.size())); };
98 bool operator == (
const secu_string &ref)
const {
return compare_with(ref.mem, *(ref.string_size)); };
108 void set(
int fd, U_I size);
119 void append_at(U_I offset,
const char *ptr, U_I size);
122 void append_at(U_I offset,
int fd, U_I size);
141 void resize(U_I size) { clean_and_destroy(); init(size); };
152 const char*
c_str()
const {
return mem ==
nullptr ?
throw SRC_BUG : mem; };
155 char *
get_array() {
return mem ==
nullptr ?
throw SRC_BUG : mem; };
161 char operator[](U_I index)
const {
return (const_cast<secu_string *>(
this))->operator[](index); };
164 U_I
get_size()
const {
if(string_size ==
nullptr)
throw SRC_BUG;
return *string_size; };
167 bool empty()
const {
if(string_size ==
nullptr)
throw SRC_BUG;
return *string_size == 0; };
177 void nullifyptr() noexcept { allocated_size = string_size =
nullptr; mem =
nullptr; };
180 void move_from(
secu_string && ref) noexcept { std::swap(allocated_size, ref.allocated_size); std::swap(mem, ref.mem); std::swap(string_size, ref.string_size); };
181 bool compare_with(
const char *ptr, U_I size)
const;
182 void clean_and_destroy();
void randomize(U_I size)
set the string to randomize string of given size
void append(const char *ptr, U_I size)
append some data at the end of the string
U_I get_allocated_size() const
get the size of the allocated secure space
bool empty() const
tell whether string is empty
are defined here basic integer types that tend to be portable
const char * c_str() const
get access to the secure string
void append(int fd, U_I size)
append some data at the end of the string
void reduce_string_size_to(U_I pos)
secu_string & operator=(const secu_string &ref)
the assignment operator
secu_string(const secu_string &ref)
the copy constructor
contains all the excetion class thrown by libdar
U_I get_size() const
get the size of the string
char & operator[](U_I index)
get access to the secure string by index
void set(int fd, U_I size)
fill the object with data
void resize(U_I size)
clear and resize the string to the defined allocated size
static bool is_string_secured()
to know if secure memory is available
void clear()
clear the string (set to an empty string)
secu_string(U_I storage_size=0)
constructor 1
~secu_string() noexcept(false)
the destructor (set memory to zero before releasing it)
void append_at(U_I offset, const char *ptr, U_I size)
append some data to the string at a given offset
secu_string(const char *ptr, U_I size)
constructor 2
char * get_array()
non constant flavor of direct secure memory access
secu_string(secu_string &&ref) noexcept
the move constructor
libdar namespace encapsulate all libdar symbols