37 class RecordFieldsMap;
48 virtual char*
tmpbuf()
const {
return 0; }
58 virtual bool is_real()
const {
return true; }
67 virtual bool write(
const void* src, uint64_t len) {
return false; }
68 virtual bool read(
void* tgt, uint64_t len) {
return false; }
69 virtual bool shift(uint64_t len) {
return false; }
71 virtual uint64_t
size()
const {
return 0; }
119 virtual bool is_real()
const {
return false; }
123 virtual bool write(
const void* src, uint64_t len) {
fLength += len;
return true; }
125 virtual bool read(
void* tgt, uint64_t len) {
return true; }
148 virtual bool shift(uint64_t len);
149 virtual bool write(
const void* src, uint64_t len);
150 virtual bool read(
void* tgt, uint64_t len);
215 void SetField(
const char * name,
const char * value);
319 bool AsBool(
bool dflt =
false)
const;
320 int64_t
AsInt(int64_t dflt = 0)
const;
321 uint64_t
AsUInt(uint64_t dflt = 0)
const;
322 double AsDouble(
double dflt = 0.)
const;
323 std::string
AsStr(
const std::string &dflt =
"")
const;
330 std::vector<std::string>
AsStrVect()
const;
335 std::string
AsJson()
const;
345 bool SetStr(
const std::string &v);
346 bool SetStr(
const char* v);
347 bool SetStrVect(
const std::vector<std::string>& vect);
352 bool SetArrInt(int64_t size, int64_t* arr,
bool owner =
false);
353 bool SetVectInt(
const std::vector<int64_t>& v);
355 bool SetArrUInt(int64_t size, uint64_t* arr,
bool owner =
false);
358 bool SetArrDouble(int64_t size,
double* arr,
bool owner =
false);
362 bool SetArrStr(int64_t size,
char* arr,
bool owner =
false);
369 static std::string
JsonReformat(
const std::string &str);
371 static bool StrToStrVect(
const char* str, std::vector<std::string>& vect,
bool verbose =
true);
376 typedef std::map<std::string, dabc::RecordField>
FieldsMap;
384 static bool match_prefix(
const std::string &name,
const std::string &prefix);
391 uint64_t
StoreSize(
const std::string &nameprefix =
"");
394 bool HasField(
const std::string &name)
const;
460 virtual bool HasField(
const std::string &name)
const
478 virtual bool SaveTo(
HStore& store,
bool create_node =
true);
484 virtual const char*
ClassName()
const {
return "Record"; }
486 virtual void Print(
int lvl = 0);
499 {
return null() ?
false :
GetObject()->HasField(name); }
502 {
return null() ?
false :
GetObject()->RemoveField(name); }
505 {
return null() ? 0 :
GetObject()->NumFields(); }
508 {
return null() ? std::string() :
GetObject()->FieldName(cnt); }
517 {
return null() ?
false :
GetObject()->SetField(name, v); }
522 GetObject()->Fields().Field(name).SetModified(on);
529 GetObject()->Fields().Field(name).SetProtected(on);
535 {
return null() ?
false :
GetObject()->SaveTo(store, create_node); }
541 std::string
SaveToXml(
unsigned mask = 0);
#define DABC_REFERENCE(RefClass, ParentClass, T)
Reference on memory from memory pool.
Interface class between xml configuration and dabc objects.
Class for holding GMT time with precision of nanoseconds.
class, used for direct store of records in JSON/XML form
void SetLimits(uint64_t v, unsigned hlimit)
void CloseNode(const char *nodename)
void SetField(const char *name, const char *value)
std::vector< int > numchilds
std::vector< int > numflds
void BeforeNextChild(const char *basename=0)
void CreateNode(const char *nodename)
Base class for most of the DABC classes.
@ flIsOwner
flag indicates default ownership for child objects
Container for records fields.
virtual ~RecordContainer()
virtual RecordField GetField(const std::string &name) const
RecordFieldsMap * TakeFieldsMap()
Remove map and returns to the user.
RecordContainer(const std::string &name, unsigned flags=flIsOwner)
virtual const char * ClassName() const
Returns class name of the object instance.
virtual bool HasField(const std::string &name) const
void SetFieldsMap(RecordFieldsMap *newmap)
Replaces existing fields map.
virtual bool SetField(const std::string &name, const RecordField &v)
virtual bool RemoveField(const std::string &name)
virtual bool SaveTo(HStore &store, bool create_node=true)
RecordFieldsMap & Fields() const
virtual void Print(int lvl=0)
Print object content on debug output.
virtual std::string FieldName(unsigned cnt) const
virtual unsigned NumFields() const
RecordFieldsMap * fFields
bool SetArrUInt(int64_t size, uint64_t *arr, bool owner=false)
Set as array, if owner flag specified, one get ownership over array and do not need to create copy.
bool fTouched
! when true, field was modified at least once
bool SetArrInt(int64_t size, int64_t *arr, bool owner=false)
Set as array, if owner flag specified, one get ownership over array and do not need to create copy.
void SetArrStrDirect(int64_t size, char *arr, bool owner=false)
RecordField(const std::vector< std::string > &v)
RecordField(const int &v)
RecordField(const double &v)
RecordField(const Buffer &buf)
bool SetVectInt(const std::vector< int64_t > &v)
RecordField(const std::vector< uint64_t > &v)
Reference * valueRef
! buffer object
RecordField(const char *v)
bool SetStr(const std::string &v)
bool SetDatime(uint64_t v)
uint64_t * arrUInt
! int array, size in valueInt
std::vector< uint64_t > AsUIntVect() const
static std::string JsonReformat(const std::string &str)
std::vector< std::string > AsStrVect() const
uint64_t valueUInt
scalar int type
uint64_t AsUInt(uint64_t dflt=0) const
RecordField(const Reference &ref)
dabc::Reference AsReference() const
RecordField(const unsigned &v)
double * arrDouble
! uint array, size in valueInt
int64_t GetArraySize() const
std::vector< int64_t > AsIntVect() const
int64_t * GetIntArr() const
bool SetVectUInt(const std::vector< uint64_t > &v)
double * GetDoubleArr() const
dabc::Buffer AsBuffer() const
bool SetArrDouble(int64_t size, double *arr, bool owner=false)
Set as array, if owner flag specified, one get ownership over array and do not need to create copy.
double valueDouble
scalar unsigned int type
std::string AsJson() const
Returns field value in JSON format.
bool SetReference(const Reference &ref)
bool SetStrVect(const std::vector< std::string > &vect)
bool AsBool(bool dflt=false) const
std::string AsStr(const std::string &dflt="") const
bool SetVectDouble(const std::vector< double > &v)
RecordField(const DateTime &v)
static bool NeedJsonReformat(const std::string &str)
int64_t AsInt(int64_t dflt=0) const
double AsDouble(double dflt=0.) const
uint64_t * GetUIntArr() const
bool SetArrStr(int64_t size, char *arr, bool owner=false)
Sets as array of string, placed one after another in memory.
RecordField(const std::vector< int64_t > &v)
std::vector< double > AsDoubleVect() const
void SetProtected(bool on=true)
bool SetValue(const RecordField &src)
RecordField(const uint64_t &v)
bool modified(bool reallychanged=true)
char * valueStr
! double array, size in valueInt
bool SetBuffer(const Buffer &buf)
Buffer * valueBuf
! string or array of strings
static bool StrToStrVect(const char *str, std::vector< std::string > &vect, bool verbose=true)
RecordField(const std::vector< double > &v)
RecordField(const bool &v)
RecordField & operator=(const RecordField &src)
RecordField(const int64_t &v)
bool fProtected
! flag, used to detect in streamer when field was touched at all
void release()
! when true, field will not be automatically deleted when full list updated from other hierarchy
RecordField(const std::string &v)
void SetModified(bool on=true)
RecordFieldsMap * Clone()
Create complete copy of fields map.
virtual ~RecordFieldsMap()
bool fChanged
true when field was removed
std::string FieldName(unsigned n) const
uint64_t StoreSize(const std::string &nameprefix="")
std::map< std::string, dabc::RecordField > FieldsMap
void ApplyDiff(const RecordFieldsMap &diff)
Apply diff map One should use fields, generated with MakeAsDiffTo call.
unsigned NumFields() const
bool WasChanged() const
Return true if any field was changed or map was modified (removed filed)
void CopyFrom(const RecordFieldsMap &src, bool overwrite=true)
Copy fields from source map.
bool HasField(const std::string &name) const
void MakeAsDiffTo(const RecordFieldsMap &src)
In the map only modified fields are remained Also dabc:delete field can appear which marks all remove...
void MoveFrom(RecordFieldsMap &src)
Move fields from source map, delete no longer existing (except protected)
RecordField & Field(const std::string &name)
Direct access to the fields.
void ClearChangeFlags()
Clear all change flags.
bool WasChangedWith(const std::string &prefix)
Returns true when fields with specified prefix were changed.
static bool match_prefix(const std::string &name, const std::string &prefix)
bool RemoveField(const std::string &name)
bool Stream(iostream &s, const std::string &nameprefix="")
bool SaveTo(HStore &res)
Save all field in json format.
dabc::Buffer SaveToBuffer()
bool SetFieldProtected(const std::string &name, bool on=true)
RecordField GetField(const std::string &name) const
unsigned NumFields() const
RecordField * GetFieldPtr(const std::string &name) const
bool ReadFromBuffer(const dabc::Buffer &buf)
bool HasField(const std::string &name) const
bool SetField(const std::string &name, const RecordField &v)
std::string SaveToJson(unsigned mask=0)
Store record in JSON form.
bool RemoveField(const std::string &name)
bool SetFieldModified(const std::string &name, bool on=true)
std::string SaveToXml(unsigned mask=0)
Store record in XML form.
std::string FieldName(unsigned cnt) const
bool SaveTo(HStore &store, bool create_node=true)
Store hierarchy in json/xml form
virtual void CreateRecord(const std::string &name)
Reference on the arbitrary object
Object * GetObject() const
Return pointer on the object.
class to stream binary data
virtual bool write(const void *src, uint64_t len)
virtual uint64_t maxstoresize() const
return maximum size of data which can be stored in the stream
virtual uint64_t tmpbuf_size() const
return number of bytes which are directly available in temporary buffer
bool write_int32(int32_t v)
bool write_uint32(uint32_t v)
bool write_int64(int64_t v)
virtual bool is_real() const
bool read_uint64(uint64_t &v)
bool read_double(double &v)
bool read_int32(int32_t &v)
virtual bool read(void *tgt, uint64_t len)
bool read_uint32(uint32_t &v)
static uint64_t str_storesize(const std::string &str)
Returns bytes count, required to store string.
virtual uint64_t size() const
return number of bytes, written or read from the stream
bool skip_object()
Insted of reading object we read size and shift on that size Only can be done where size stored as 32...
bool write_uint64(uint64_t v)
bool read_int64(int64_t &v)
bool read_str(std::string &str)
Restore string from the stream.
bool write_double(double v)
virtual bool shift(uint64_t len)
bool write_str(const std::string &str)
Store string in the stream.
bool verify_size(uint64_t pos, uint64_t sz)
virtual char * tmpbuf() const
return temporary buffer
iostream class, which write and read data from memory
virtual uint64_t maxstoresize() const
return maximum size of data which can be stored in the stream
memstream(bool isinp, char *buf, uint64_t len)
virtual bool write(const void *src, uint64_t len)
virtual bool shift(uint64_t len)
virtual uint64_t tmpbuf_size() const
return number of bytes which are directly available in temporary buffer
virtual bool read(void *tgt, uint64_t len)
virtual uint64_t size() const
return number of bytes, written or read from the stream
virtual char * tmpbuf() const
return temporary buffer
special class only to define how many data will be written to the stream
virtual bool write(const void *src, uint64_t len)
virtual bool shift(uint64_t len)
virtual uint64_t size() const
return number of bytes, written or read from the stream
virtual bool read(void *tgt, uint64_t len)
virtual bool is_real() const
virtual uint64_t maxstoresize() const
return maximum size of data which can be stored in the stream