25 #include <boost/archive/iterators/base64_from_binary.hpp>
26 #include <boost/archive/iterators/binary_from_base64.hpp>
27 #include <boost/archive/iterators/transform_width.hpp>
28 #include <boost/archive/iterators/insert_linebreaks.hpp>
29 #include <boost/archive/iterators/remove_whitespace.hpp>
43 constexpr
unsigned char TAB[64]={46, 61, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122};
47 return (val >> bitPos) & 0x1;
50 unsigned char BitAtPos(
char pt0,
char pt1, std::size_t bitPos)
58 unsigned char ChunkInternal(
char pt0,
char pt1, std::size_t startBitIdInByte)
63 ret |=
BitAtPos(pt0,pt1,startBitIdInByte+
i);
70 unsigned char ChunkAtPos(
const char *pt, std::size_t len, std::size_t posChunk)
72 std::size_t startByte((posChunk*
NB_BITS)/8);
73 std::size_t startBitIdInByte((posChunk*
NB_BITS)%8);
74 char pt1(startByte!=len-1?pt[startByte+1]:pt[startByte]);
87 const char *bytesPt(bytes.c_str());
88 std::size_t input_len(bytes.size());
89 std::size_t input_len_bit(input_len*8);
91 std::string ret(nb_chunks,
'\0');
92 for(std::size_t
i=0;
i<nb_chunks;++
i)
104 constexpr
unsigned char TAB2[
MAX_VAL_TAB2] = {
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL, 0,
NOT_OK_VAL, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL, 1,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL,
NOT_OK_VAL, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 };
108 return ( val >> (5-bitPos) ) & 0x1;
123 unsigned char ret(
TAB2[(
unsigned char)
c]);
133 unsigned char ret(0);
135 for(
int i = 7;
i>=0; --
i)
144 char ByteAtPos(
const char *chunckPt, std::size_t bytePos)
146 std::size_t startChunk((bytePos*8)/
NB_BITS);
147 std::size_t startBitId((bytePos*8)%
NB_BITS);
148 return ByteInternal(chunckPt[startChunk],chunckPt[startChunk+1],startBitId);
153 std::size_t nb_chunks(bytes.size());
154 const char *chunckPt(bytes.c_str());
155 std::size_t nb_bytes_output((nb_chunks*
NB_BITS)/8);
156 std::string ret(nb_bytes_output,
'\0');
157 for(std::size_t
i = 0;
i<nb_bytes_output; ++
i)
185 _str=(
char *)malloc(len+1);
186 std::copy(val,val+len,
_str);
192 _str=(
char *)malloc(val.size()+1);
193 std::copy(val.cbegin(),val.cend(),
_str);
194 _str[val.size()]=
'\0';
253 for(std::size_t
i=0;
i<
sizeof(
void *) && isNull;
i++)
312 void **tmp=(
void **)data;
331 return new AtomAny(val,dealloc);
346 throw Exception(
"AtomAny::operator[] : try to get a part of a partitionned data whereas atomical.");
387 throw Exception(
"Value is not a double");
401 throw Exception(
"Value is not a string");
412 throw Exception(
"Value is not a string");
452 void **tmp1=(
void **)src;
475 void **tmp=(
void **)data;
512 throw Exception(
"AtomAny::operator[] : try to get a part of a partitionned data not localizable by a string.");
518 throw Exception(
"ComposedAny::checkTypeOf : invalid type.");
542 _start(0),_finish(0),_endOfStorage(0)
550 _start(0),_finish(0),_endOfStorage(0)
583 memcpy(
_start,mem,sizeInByte);
613 return (
char *)::operator
new(nbOfByte);
624 ::operator
delete(pt);
645 std::vector<unsigned int> ret;
646 unsigned int sz(
size());
647 for(
unsigned int i=0;
i<sz;
i++)
691 if(!((*(*
this)[
i])==(*otherC[
i])))
714 const void *tmp=(
const void *)
this;
716 const void **tmp2=(
const void **) data;
723 void **tmp2=(
void **) src;
739 void **tmp=(
void **) data;
747 void **tmp=(
void **) data;
760 std::size_t sz(its.size());
762 for(std::size_t
i=0;
i<sz;
i++)
803 _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
808 _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
814 _alloc(
Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
820 _alloc(
Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
826 _alloc(
Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
832 _alloc(
Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
838 _alloc(
Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
840 for(vector<bool>::const_iterator iter=val.begin();iter!=val.end();iter++)
848 _alloc(
Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
854 _alloc(
Runtime::_tc_string->getSizeInByteOfAnyReprInSeq())
856 for(vector<string>::const_iterator iter=val.begin();iter!=val.end();iter++)
896 for(
unsigned i=0;
i<
size;
i++,tmp+=sizePerContent)
968 for(vector<std::string>::const_iterator iter=val.begin();iter!=val.end();iter++,
i++)
971 memcpy(
_data+
i*sizePerContent,&st,sizePerContent);
989 if(!((*(*
this)[
i])==(*otherC[
i])))
999 throw Exception(
"Trying to access to an invalid index in an Any Tuple");
1015 return new ArrayAny(typeOfContent,lgth);
1031 subType->
putReprAtPlace(data+
i*sizePerContent,src+
i*sizePerContent,deepCpy);
1052 return (typ==
Array);
1065 vector< pair<string,TypeCode*> >::const_iterator iter;
1067 if(!((*(*
this)[(*iter).first.c_str()]==(*other[(*iter).first.c_str()]))))
1074 const char what[]=
"StructAny::operator[](int i) : Struct key are strings not integers.";
1081 char *whereToGet=
_data;
1082 vector< pair<string,TypeCode*> >::const_iterator iter;
1084 if((*iter).first!=key)
1085 whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1090 string what(
"Unexisting key \""); what+=key; what+=
"\" for struct extraction.";
1093 return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
1098 const char what[]=
"Struct key are strings not integers.";
1108 throw Exception(
"StructAny::setEltAtRank : invalid key given.");
1110 throw Exception(
"StructAny::setEltAtRank : invalid data type on the specified given key.");
1119 vector< pair<string,TypeCode*> >::const_iterator iter;
1123 offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1130 vector< pair<string,TypeCode*> >::const_iterator iter;
1133 (*iter).second->putReprAtPlace(data+offset,src+offset,deepCpy);
1134 offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1140 char *whereToGet=data;
1141 vector< pair<string,TypeCode*> >::const_iterator iter;
1144 (*iter).second->destroyZippedAny(whereToGet);
1145 whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1159 vector< pair<string,TypeCode*> >::const_iterator iter;
1160 char *whereToGet=
_data;
1163 (*iter).second->destroyZippedAny(whereToGet);
1164 whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1180 vector< pair<string,TypeCode*> >::const_iterator iter;
1185 offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1192 vector< pair<string,TypeCode*> >::const_iterator iter;
1196 (*iter).second->putReprAtPlace(
_data+offset,data+offset,
false);
1197 offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
char ByteAtPos(const char *chunckPt, std::size_t bytePos)
unsigned char BitAtPosSimple2(char val, std::size_t bitPos)
unsigned char CheckEntry(char c)
unsigned char ChunkInternal(char pt0, char pt1, std::size_t startBitIdInByte)
unsigned char BitAtPosSimple(char val, std::size_t bitPos)
char BitAtPosOnChunk(char pt0, char pt1, std::size_t bitPos)
unsigned char ChunkAtPos(const char *pt, std::size_t len, std::size_t posChunk)
char ByteInternal(char c0, char c1, std::size_t startBitIdInByte)
constexpr unsigned char TAB2[MAX_VAL_TAB2]
constexpr unsigned char TAB[64]
constexpr unsigned NB_BITS
unsigned char BitAtPos(char pt0, char pt1, std::size_t bitPos)
std::size_t OnOff(std::size_t i)
constexpr unsigned MAX_VAL_TAB2
constexpr unsigned NOT_OK_VAL
: Allow to manage memory of instances of T. The only constraint on T is to have method incrRef and De...
: Interface for management of storage of data formated dynamically in its TypeCode....
virtual void putMyReprAtPlace(char *data) const =0
static bool IsNull(char *data)
const TypeCode * getType() const
static AnyPtr getOrBuildFromData(char *data, const TypeCodeArray *type)
bool operator==(const Any &other) const
static void destroyReprAtPlace(char *data, const TypeCodeArray *type)
void putMyReprAtPlace(char *data) const
AnyPtr operator[](int i) const
void setEltAtRank(int i, const Any *elem)
static void putReprAtPlace(char *data, const char *src, const TypeCodeArray *type, bool deepCpy)
static ArrayAny * New(const std::vector< T > &vec)
static bool takeInChargeStorageOf(TypeCode *type)
unsigned int size() const
AnyPtr operator[](int i) const
static bool takeInChargeStorageOf(TypeCode *type)
static void putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy)
static AnyPtr getOrBuildFromData(char *data, const TypeCode *type)
bool operator==(const Any &other) const
std::string getStringValue() const
double getDoubleValue() const
static AtomAny * New(T val)
const char * getBytesValue(std::size_t &len) const
void putMyReprAtPlace(char *data) const
static void destroyReprAtPlace(char *data, const TypeCode *type)
bool getBoolValue() const
void checkTypeOf(const Any *elem) const
AnyPtr operator[](const char *key) const
bool getBoolValue() const
double getDoubleValue() const
ComposedAny(const ComposedAny &other)
std::string getStringValue() const
static YACS::ENGINE::TypeCode * _tc_double
static YACS::ENGINE::TypeCode * _tc_bool
static YACS::ENGINE::TypeCode * _tc_int
static YACS::ENGINE::TypeCode * _tc_string
SeqAlloc(const SeqAlloc &other)
void destroy(char *pt, const TypeCode *tc)
void construct(char *pt, const Any *val)
const unsigned int _sizeOf1Elm
void initCoarseMemory(char *mem, unsigned int size, Deallocator dealloc)
static const char DFT_CHAR_VAR
char * allocate(unsigned int nbOfByte)
unsigned int size() const
Deallocator _notStdDeAlloc
void deallocate(char *pt)
std::vector< unsigned int > getSetItems() const
void setEltAtRank(int i, const Any *elem)
unsigned int size() const
AnyPtr operator[](int i) const
static void putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy)
std::vector< unsigned int > getSetItems() const
SequenceAny * removeUnsetItemsFromThis() const
bool operator==(const Any &other) const
void putMyReprAtPlace(char *data) const
static void destroyReprAtPlace(char *data, const TypeCode *type)
static bool takeInChargeStorageOf(TypeCode *type)
void realloc(char *endOfCurrentAllocated, const Any *elem)
void pushBack(const Any *elem)
char * performCpy(char *srcStart, char *srcFinish, char *destStart)
static SequenceAny * New(const std::vector< T > &vec)
static AnyPtr getOrBuildFromData(char *data, const TypeCode *type)
StringOnHeap(const char *val)
StringOnHeap * deepCopy() const
bool operator==(const StringOnHeap &other) const
const char * cStr() const
static AnyPtr getOrBuildFromData(char *data, const TypeCodeStruct *type)
static StructAny * New(TypeCodeStruct *type)
AnyPtr operator[](int i) const
void putMyReprAtPlace(char *data) const
bool operator==(const Any &other) const
static void putReprAtPlace(char *data, const char *src, const TypeCodeStruct *type, bool deepCpy)
static void destroyReprAtPlace(char *data, const TypeCodeStruct *type)
void setEltAtRank(int i, const Any *elem)
virtual const TypeCode * contentType() const
unsigned getStaticLgth() const
Class for sequence objects.
const TypeCode * getMember(const std::string &name, unsigned &offset) const
Get typecode of struct member given its name.
std::vector< std::pair< std::string, TypeCode * > > _members
Base class for all type objects.
virtual void destroyZippedAny(char *data) const
virtual const TypeCode * contentType() const
virtual int isA(const char *repositoryId) const
virtual unsigned getSizeInByteOfAnyReprInSeq() const
virtual void putReprAtPlace(char *pt, const char *val, bool deepCpy) const
virtual AnyPtr getOrBuildAnyFromZippedData(char *data) const
YACSLIBENGINE_EXPORT std::string FromBase64Safe(const std::string &bytes)
void(* Deallocator)(void *)
YACSLIBENGINE_EXPORT std::string ToBase64(const std::string &bytes)
YACSLIBENGINE_EXPORT std::string FromBase64(const std::string &bytes)