40 const std::string &
file,
68 template <
typename T>
void SdsArgPut(
72 template <>
void SdsArgPut<bool>(
75 template <>
void SdsArgPut<char>(
78 template <>
void SdsArgPut<short>(
81 template <>
void SdsArgPut<unsigned short>(
84 template <>
void SdsArgPut<INT32>(
87 template <>
void SdsArgPut<UINT32>(
90 template <>
void SdsArgPut<INT64>(
93 template <>
void SdsArgPut<UINT64>(
96 template <>
void SdsArgPut<float>(
99 template <>
void SdsArgPut<double>(
103 template <>
void SdsArgPut<const char *>(
117 template <
typename T>
void SdsArgGet(
121 template <>
void SdsArgGet<bool>(
124 template <>
void SdsArgGet<char>(
127 template <>
void SdsArgGet<short>(
130 template <>
void SdsArgGet<unsigned short>(
133 template <>
void SdsArgGet<INT32>(
136 template <>
void SdsArgGet<UINT32>(
139 template <>
void SdsArgGet<INT64>(
142 template <>
void SdsArgGet<UINT64>(
145 template <>
void SdsArgGet<float>(
148 template <>
void SdsArgGet<double>(
151 template <>
void SdsArgGet<std::string>(
171 template <
typename T>
void PutScalar(
175 template <>
void PutScalar<bool>(
178 template <>
void PutScalar<char>(
181 template <>
void PutScalar<short>(
184 template <>
void PutScalar<unsigned short>(
187 template <>
void PutScalar<INT32>(
190 template <>
void PutScalar<UINT32>(
193 template <>
void PutScalar<INT64>(
196 template <>
void PutScalar<UINT64>(
199 template <>
void PutScalar<float>(
202 template <>
void PutScalar<double>(
206 template <>
void PutScalar<const char *>(
210 template <>
void PutScalar<const std::string &>(
226 template <
typename T>
void GetScalar(
230 template <>
void GetScalar<bool>(
233 template <>
void GetScalar<char>(
236 template <>
void GetScalar<short>(
239 template <>
void GetScalar<unsigned short>(
242 template <>
void GetScalar<INT32>(
245 template <>
void GetScalar<UINT32>(
248 template <>
void GetScalar<INT64>(
251 template <>
void GetScalar<UINT64>(
254 template <>
void GetScalar<float>(
257 template <>
void GetScalar<double>(
260 template <>
void GetScalar<std::string>(
278 virtual void Print(
const std::string &
line) = 0;
283 class PrintObjectCR {
293 virtual void Print(
const std::string &
line)
const = 0;
422 void CleanUp(
const std::string &
from_where)
noexcept {
423#if defined(SDS_CHECK_FREE)||defined(SDS_CHECK_FREE_W)
434 void CleanUpWorker(
bool check,
const std::string &
from_where)
noexcept;
441 template <
class ContainerType>
458 "SDS type does not match expected array type");
460 if (
dims->size() == 0)
463 "Attempt to access an array in an SDS structure which is not an array");
465 if (
dims->size() !=
static_cast<unsigned>(
ndims))
468 "SDS Array structure has % dimensions instead of the expected %",
477 void CheckArrayTypeSingleDim(
479 unsigned long *
const nitems)
const {
481 std::vector<unsigned long>
dims;
482 CheckArrayType(code, 1, &
dims);
492 template <
class T>
void SetArrayHelperDataAddr(
493 T *
const data)
const {
558 CleanUp(
"sds::Id move assignment");
561 _flags = std::move(
rhs._flags);
588 _flags.readfree =
false;
620 const bool del =
false,
const bool readfree =
false) :
624 _flags.readfree = readfree;
671 const bool del =
false,
const bool readfree =
false);
752 template <
class ContainerType>
761 std::is_standard_layout<typename ContainerType::value_type>::value,
762 "The value type in the container must be a standard layout type");
767 "Attempt to access data in empty container");
769 Id item(0,
true,
false,
false);
800 template <
class ContainerType>
808 std::is_standard_layout<typename ContainerType::value_type>::value,
809 "The value type in the container must be a standard layout type");
815 "Attempt to access data in empty container");
819 Id item(0,
true,
true,
false);
863 const std::string &name,
865 const std::string &
extra =
"")
const;
881 const std::string &name,
883 const std::string &
extra =
"");
915 template <
class ContainerType>
917 const std::string &name,
920 const std::string &
extra =
"")
const {
922 Id item(0,
true,
false,
false);
934 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
983 const std::string &name,
985 const unsigned nElem,
986 const std::string &
extra =
"")
const {
988 Id item(0,
true,
false,
false);
995 unsigned long dims[1];
1032 template <
class ContainerType>
1034 const std::string & name,
1037 const std::string &
extra =
""){
1039 Id item(0,
true,
true,
false);
1051 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
1098 const std::string & name,
1100 const unsigned nElem,
1101 const std::string &
extra =
""){
1103 Id item(0,
true,
true,
false);
1110 unsigned long dims[1];
1157 template <
class ContainerType>
1160 Id item(0,
true,
false,
false);
1171 "Failed to access SDS array cell - % dimensions, minimum supported 1, maximum supported is %",
1190 item._flags.del =
false;
1196 "Failed to access cell of existing SDS array id");
1237 virtual Id Find(
const std::string &name,
1287 CleanUp(
"sds::Id destructor");
1296 virtual void SetFree() { _flags.free =
true; }
1302 virtual void SetDelete() { _flags.del =
true; }
1324 _flags.free =
false;
1326 _flags.readfree =
false;
1363 _flags.free =
false;
1382 if (!
Exists(name))
return;
1415 template <
class ContainerType>
1425 std::is_standard_layout<typename ContainerType::value_type>::value,
1426 "The value type in the container must be a standard layout type");
1461 template <
class ContainerType>
1469 std::is_standard_layout<typename ContainerType::value_type>::value ,
1470 "The value type in the container must be a standard layout type");
1507 _flags.readfree =
false;
1521 virtual void Flush() {
1558 template <
typename T>
1561 unsigned long *
actlen =
nullptr,
1562 const unsigned long offset=0)
const {
1570 std::is_standard_layout<T>::value,
1571 "The type T must be a standard layout type");
1593 virtual std::string
GetExtra()
const {
1595 unsigned long length = 0;
1612 "Failed to Get extra data from SDS item");
1625 virtual std::string
GetName()
const {
1633 "Failed to Get Name of SDS item");
1686 "SDS Item % has code %, was expected to have code %",
1715 template <
class ContainerType>
1724 "Failed to Get dimensions of SDS item");
1752 "Failed to Get number of SDS items");
1802 template <
class ContainerType>
1816 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
1896 template <
typename T>
1906 std::is_standard_layout<T>::value,
1907 "The type T must be a standard layout and type");
1921 *data =
static_cast<T *
>(
tdata);
1952 template <
typename T>
1954 const T *
const data,
1955 const unsigned long offset=0) {
1963 std::is_standard_layout<T>::value,
1964 "The type T must be a standard layout type");
1966 const void *
tdata =
static_cast<const void *
>(data);
2001 virtual void Rename(
const std::string &name) {
2034 template <
class ContainerType>
2048 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
2074 virtual unsigned long Size()
const {
2075 unsigned long bytes;
2097 unsigned long bytes;
2110 virtual void List()
const {
2140 virtual void List(std::ostream &
strm,
2207 "Failed to write SDS structure to file \"%\"",
2247 "Failed to get SDS external structure address");
2268 virtual bool Exists(
const std::string &name)
const;
2282 virtual bool Exists(
unsigned index)
const;
2296 explicit operator SdsIdType()
const {
return _id; }
2303 explicit operator bool()
const {
2335 bool *
const del= 0,
bool *
const readfree = 0) {
2337 *free = _flags.free;
2341 *readfree = _flags.readfree;
2343 _flags.free = _flags.del = _flags.readfree =
false;
2368 CleanUp(
"sds::Id::ShallowCopy 1");
2370 _flags.free = _flags.del = _flags.readfree =
false;
2397 CleanUp(
"sds::Id::ShallowCopy 2");
2405 _flags.free =
source->_flags.free;
2406 _flags.del =
source->_flags.del;
2407 _flags.readfree =
source->_flags.readfree;
2410 source->_flags.readfree =
false;
2414 _flags.free = _flags.del = _flags.readfree =
false;
2440 const bool del =
false,
const bool readfree =
false) {
2441 CleanUp(
"sds::Id::ShallowCopy 3");
2444 _flags.readfree = readfree;
2467 _flags.del, _flags.readfree);
2468 _flags.free =
false;
2470 _flags.readfree =
false;
2477 target->ShallowCopy(_id);
2521 CheckArrayTypeSingleDim(data->Code(),
dims);
2522 data->SetNumElements(
dims[0]);
2523 SetArrayHelperDataAddr(data);
2562 const unsigned long nitems,
2563 sds::ArrayAccessHelper<T> *
const data)
const {
2566 CheckArrayTypeSingleDim(data->Code(),
dims);
2570 "ArrayAccess expected % items, found %",
2573 data->SetNumElements(
dims[0]);
2574 SetArrayHelperDataAddr(data);
2620 template <
typename T,
class ContainerType>
void ArrayAccess(
2630 "Failed to access SDS array. Numbers of dimensions % invalid, must be in range 1 to %",
2634 CheckArrayType(data->Code(),
ndims,
dims);
2639 unsigned long elements = (*dims)[0];
2640 for (
unsigned long i = 1;
i <
dims->size() ; ++
i)
2644 data->SetNumElements(elements);
2648 SetArrayHelperDataAddr(data);
2697 template <
typename T,
class ContainerType>
void ArrayAccess(
2756 const std::string &name,
2759 const std::string &
extra =
"") {
2763 data->SetNumElements(
nitems);
2764 arrayId.SetArrayHelperDataAddr(data);
2821 const std::string &name,
2823 sds::ArrayWriteHelper<T> *
const data,
2824 const std::string &
extra =
"") {
2831 unsigned long elements =
dims[0];
2832 for (
unsigned long i = 1;
i <
dims.size() ; ++
i)
2837 data->SetNumElements(elements);
2838 arrayId.SetArrayHelperDataAddr(data);
2892 template <
typename ContainerType>
2895 const std::string &name=
"ArgStructure") {
2948 template <
typename T>
2950 const std::initializer_list<T> &
values,
2951 const std::string &name=
"ArgStructure") {
2984 template <
typename T>
2987 const std::string &name=
"ArgStructure") {
3024 template <
typename ContainerType>
3063 char *
string =
new char[
maxlen];
3076 std::string
result=&
string[0];
3107 template <
typename T>
3120 "ArgPut failed of item \"%\" failed",
3141 void Put (
const std::string &name,
const std::string &
value,
3149 "ArgPut failed of item \"%\" failed",
3177 template <
typename T>
3178 void Get (
const std::string &name, T *
value)
const {
3190 "ArgGet failed of item \"%\" failed",
3213 template <
typename T>
3236 void Put (
const std::string &
value) {
3257 template <
typename T>
3295 template <
class ContainerType>
3311 "Failed to check SDS array - % dimensions, minimum supported 0, maximum supported is %",
3335 virtual int GetInt()
const;
3341 virtual unsigned int GetUInt()
const;
3354 virtual unsigned long GetULong()
const;
3379 nullptr,
nullptr,
nullptr, &
status);
3399 std::string _function;
3422 : _line(
line), _file(
file), _function(function) {
3436 fprintf(
stderr,
"Warning:sds::IdChecker:Function leaked SDS id's - function %s, file %s, check object at line %d\n", _function.c_str(), _file.c_str(), _line);
3438 fprintf(
stderr,
"Warning:sds::IdChecker:Function released SDS id's - function %s, file %s, check object at line %d\n", _function.c_str(), _file.c_str(), _line);
3452#define SDS_CHECK_IDS2(function_) drama::sds:IdChecker _sds_id_checker(__LINE__, __FILE__, (function_))
3457 typedef std::shared_ptr<Id>
IdPtr;
3468 void operator()(
void *)
const { }
3489 template <
typename T>
3490 class DataPointer :
public std::unique_ptr<T,_nodel> {
3493 unsigned long _lengthBytes;
3511 std::is_standard_layout<T>::value,
3512 "The type T must be a standard layout and type");
3517 if (_lengthBytes !=
sizeof(T))
3520 "SDS Pointer error - expected % bytes, got %",
3521 sizeof(T), _lengthBytes);
3526 std::unique_ptr<T, _nodel>
p(
dataPnt, _nodel());
3528 *((std::unique_ptr<T,_nodel>*)(
this)) = std::move(
p);
3550 std::is_standard_layout<T>::value,
3551 "The type T must be a standard layout type");
3556 if (_lengthBytes !=
sizeof(T))
3559 "SDS Pointer error - expected % bytes, got %",
3560 sizeof(T), _lengthBytes);
3565 std::unique_ptr<T, _nodel>
p(
dataPnt, _nodel());
3567 *((std::unique_ptr<T,_nodel>*)(
this)) = std::move(
p);
3592 return _lengthBytes;
3615 template <
typename T>
3616 class DataPointer<T[]> :
public std::unique_ptr<T[], _nodel> {
3619 unsigned long _numItems;
3620 unsigned long _lengthBytes;
3517 if (_lengthBytes !=
sizeof(T)) {
…};
3624 typedef T * iterator;
3626 typedef const T * const_iterator;
3628 typedef T value_type;
3648 std::is_standard_layout<T>::value,
3649 "The type T must be a standard layout type");
3654 if (_lengthBytes <
sizeof(T))
3657 "SDS Array Pointer error - expected at least % bytes, got %",
3658 sizeof(T), _lengthBytes);
3663 _numItems = _lengthBytes/
sizeof(
dataPnt[0]);
3668 *((std::unique_ptr<T[],_nodel>*)(
this)) = std::move(
p);
3691 std::is_standard_layout<T>::value,
3692 "The type T must be a standard layout type");
3697 if (_lengthBytes <
sizeof(T))
3700 "SDS Array Pointer error - expected at least % bytes, got %",
3701 sizeof(T), _lengthBytes);
3706 _numItems = _lengthBytes/
sizeof(
dataPnt[0]);
3711 *((std::unique_ptr<T[],_nodel>*)(
this)) = std::move(
p);
3734 unsigned long size()
const {
3742 return _lengthBytes;
3749 return & (*this)[0];
3756 return (&(*
this)[0])+_numItems;
3762 const_iterator begin()
const {
3763 return & (*this)[0];
3769 const_iterator end()
const {
3770 return (&(*
this)[0])+_numItems;
3779 const_iterator cbegin()
const {
3780 return & (*this)[0];
3790 return (&(*
this)[0])+_numItems;
3803 bool empty()
const {
3850 using iterator_category = std::forward_iterator_tag;
3851 using value_type =
Id;
3852 using difference_type =std::ptrdiff_t;
3853 using pointer =
Id*;
3854 using reference =
Id&;
3862 bool _isArray =
false;
3887 "Attempt to construct IdIterator on non-structured SDS item (code %)", _top.
GetCode());
3893 std::vector<unsigned>
dims;
3895 if (
dims.size() > 0)
3909 "Attempt to construct IdIterator on an array of structures with more then 1 dimension - can't yet do that. ");
3915 _endCell =
dims[0]+1;
3924 _endCell =
id.GetNumItems()+1;
3931 _curCell = _endCell;
3943 if (&_top != &
other._top)
3945 return _curCell !=
other._curCell;
3954 if (_curCell >= _endCell)
3957 "Attempt to dereference IdIterator past end of structure");
3962 std::vector<unsigned long>
indicies(1);
3966 return _top.
Index(_curCell);
3981 if (_curCell < _endCell)
4010 template <
typename T>
4011 class ArrayContainer {
4020 T *_address =
nullptr;
4032 std::is_standard_layout<T>::value,
4033 "The type T must be a standard layout and type");
4039 bool empty()
const {
4040 return (_size <= 0);
81 template <>
void SdsArgPut<unsigned short>( {
…}
SdsCodeType Code() const
Return the SDS type code of the item being accessed.
Definition sdsarray.hh:262
Helper class for access to an SDS Scalar Arrays.
Definition sdsarray.hh:180
size_type size() const
Returns the size of the container in items.
Definition sds.hh:4073
reference operator[](size_type n)
Returns an item at a particular address.
Definition sds.hh:4081
bool empty() const
Returns true if the container is empty.
Definition sds.hh:4066
value_type & reference
The type for a reference to the value.
Definition sds.hh:4043
T value_type
The value type.
Definition sds.hh:4041
ArrayContainer(T *address, size_type size)
Create a container to access the array.
Definition sds.hh:4056
std::size_t size_type
The type used for sizes.
Definition sds.hh:4045
~ArrayContainer()
Destroy the container, not the underlying array item.
Definition sds.hh:4086
A container for simple arrays for use with SDS templates.
Definition sds.hh:4038
Helper class for writing data to SDS Scalar Arrays.
Definition sdsarray.hh:303
const_iterator cend() const
Returns a const iterator pointing to the past-the-end element in the array.
Definition sds.hh:3816
iterator begin()
Returns an iterator pointing to the first element in the array.
Definition sds.hh:3775
const_iterator cbegin() const
Returns a const iterator pointing to the first element in the array.
Definition sds.hh:3806
bool empty() const
Returns true if container is empty.
Definition sds.hh:3830
const T * const_iterator
const iterator for this item
Definition sds.hh:3653
iterator end()
Returns an iterator pointing to the past-the-end element in the array.
Definition sds.hh:3782
unsigned long size() const
Return the number of elements in the array.
Definition sds.hh:3761
DataPointer(const drama::sds::Id &theId)
DataPointer Constructor.
Definition sds.hh:3666
const_iterator begin() const
Returns a const iterator pointing to the first element in the array.
Definition sds.hh:3789
unsigned long NumBytes() const
Return the size of the item in bytes.
Definition sds.hh:3768
~DataPointer()
DataPointer destructor.
Definition sds.hh:3748
T * iterator
iterator for this item
Definition sds.hh:3651
T value_type
Returns the type of T
Definition sds.hh:3655
DataPointer(drama::sds::Id *theId, bool outlives=false)
DataPointer Constructor.
Definition sds.hh:3709
const_iterator end() const
Returns a const iterator pointing to the past-the-end element in the array.
Definition sds.hh:3796
unsigned long NumBytes() const
Return the size of the item in bytes.
Definition sds.hh:3618
DataPointer(drama::sds::Id *theId, bool outlives)
DataPointer Constructor.
Definition sds.hh:3568
~DataPointer()
DataPointer destructor.
Definition sds.hh:3605
DataPointer(const drama::sds::Id &theId)
DataPointer Constructor.
Definition sds.hh:3530
A class that provides direct access to the data of an SDS item, via a sub-class of std::unique_ptr<>.
Definition sds.hh:3517
IdChecker(int line, const char *file, const char *function)
Construct an SdsChecker object.
Definition sds.hh:3448
virtual ~IdChecker()
SdsCheck destructor.
Definition sds.hh:3459
A class to check for SDS leaks.
Definition sds.hh:3421
IdIterator(const Id &id, const bool setEnd=false)
Construct a forward iterator for working through an SDS structure or array of structures.
Definition sds.hh:3906
bool operator!=(const IdIterator &other) const
Inequality operator.
Definition sds.hh:3968
Id operator*() const
Dereference operator - return the sds::Id item the iterator is pointing to.
Definition sds.hh:3980
const IdIterator & operator++()
Increment operator (prefix version).
Definition sds.hh:4002
An iterator for working through SDS Structures and SDS arrays of structures.
Definition sds.hh:3875
virtual void SetFree()
Indicate the underlying SDS item should be free-ed when the sds::Id object is destroyed.
Definition sds.hh:1323
virtual unsigned long GetULong() const
If the SDS item refers to a scalar value, convert it to an unsigned long integer.
Id CreateChildArray(const std::string &name, const SdsCodeType code, const unsigned nElem, const std::string &extra="") const
Factory constructor method Constructor which creates a new child item which is a one-dimensional arra...
Definition sds.hh:1009
Id & operator=(Id &&rhs) noexcept
Move assignment operator.
Definition sds.hh:582
virtual std::string GetName() const
Return the name of the SDS item.
Definition sds.hh:1652
virtual std::string GetExtra() const
Get extra data from an SDS item.
Definition sds.hh:1620
virtual Id CreateChildItem(const std::string &name, const SdsCodeType code, const std::string &extra="") const
Factory constructor method which creates a new (non-array) child item.
void Resize(const ContainerType &dims)
Change the dimensions of an SDS array.
Definition sds.hh:2062
static Id FromFile(const std::string &filename)
Factory constructor method that reads an SDS structure from a file.
Id ArrayCreateAndAccess(const std::string &name, const unsigned nitems, sds::ArrayWriteHelper< T > *const data, const std::string &extra="")
Create a new child of primitive items and access that array, one dimensional.
Definition sds.hh:2782
void Get(const std::string &name, T *value) const
Fetch primitive value from a named component of the structure.
Definition sds.hh:3205
virtual void ClearDelete()
Indicate the underlying SDS structure should NOT be deleted when the sds::Id object is destroyed.
Definition sds.hh:1339
virtual bool Exists(unsigned index) const
Determine if a item of a given index exists in a structure.
void CheckItem(SdsCodeType code, const ContainerType &dims) const
Check an item has a required structure.
Definition sds.hh:3323
unsigned GetNumItems() const
Return the number of components in an SDS structure.
Definition sds.hh:1772
virtual long GetLong() const
If the SDS item refers to a scalar value, convert it to long integer.
virtual void Outlive()
Force the actual SDS ID to outlive the sds::Id variable.
Definition sds.hh:1350
void ArrayAccess(const unsigned long nitems, sds::ArrayAccessHelper< T > *const data) const
Access the data of a single dimensional SDS primitive item array of a specified number of elements.
Definition sds.hh:2588
void ArrayAccess(ArrayAccessHelper< T > *const data) const
Access the data of a single dimensional SDS primitive array item of a specified number of elements.
Definition sds.hh:2544
static Id CreateArgCmdStruct(const ContainerType &values, const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure in the DRAMA Command style.
Definition sds.hh:2920
virtual void List(const PrintObjectCR &printer, int lineMaxLen=100) const
List the contents of the structure via a PrintObjectCR.
virtual void SetDelete()
Indicate the underlying SDS structure should be deleted when the sds::Id object is destroyed.
Definition sds.hh:1329
virtual Id Find(const std::string &name, bool throwOnNotFound=true) const
Factory constructor method Constructor which returns a reference to a named item.
static Id CreateByAccess(ContainerType *container)
Factory constructor method that accesses an exported SDS structure found in a byte stream.
Definition sds.hh:780
virtual unsigned long SizeDefined() const
Return the size of an SDS structure, as required for exporting when fully defined.
Definition sds.hh:2123
virtual void Write(const std::string &filename) const
Write the contents of the structure to a file.
Definition sds.hh:2229
virtual void Rename(const std::string &name)
Rename the SDS item.
Definition sds.hh:2028
virtual void List() const
List the contents of the structure to standard output.
Definition sds.hh:2137
void Put(const std::string &name, const std::string &value, const std::string &extraData="")
Insert a string value into a named component of the structure.
Definition sds.hh:3168
static Id CreateFromSdsId(SdsId *item)
Factory constructor method that constructs an sds::Id item from an existing old C++ interface SdsId i...
virtual void DeleteIfExists(const std::string &name)
Delete the named SDS item within the current structured item.
Definition sds.hh:1407
virtual unsigned int GetUInt() const
If the SDS item refers to a scalar value, convert it to an unsigned integer.
Id ArrayCreateAndAccess(const std::string &name, const ContainerType &dims, sds::ArrayWriteHelper< T > *const data, const std::string &extra="")
Create a new child of primitive items and access that array, multi-dimensional.
Definition sds.hh:2847
void Put(T value)
Insert a primitive value into the item.
Definition sds.hh:3241
Id & operator=(const Id &rhs)=delete
Assignment operator - deleted.
virtual double GetDouble() const
If the SDS item refers to a scalar value, convert it to a double item.
void Insert(Id &to_insert, const ContainerType &dims)
Insert an SDS object into this object, which is a structured array.
Definition sds.hh:1830
Id Cell(const ContainerType &indicies, bool throwOnNotFound=true) const
Factory constructor method Constructor that returns a cell of an existing id which must refer to an S...
Definition sds.hh:1185
virtual void ToSdsId(::SdsId *target, const bool outlives=false)
Shallow copy to an SdsId type.
Definition sds.hh:2486
static Id CreateByImport(const ContainerType &container)
Factory constructor method that imports an exported SDS structure found in a byte stream.
Definition sds.hh:828
virtual void List(FILE *to) const
List the contents of the structure to a C file.
Definition sds.hh:2149
virtual void ValidateCode(SdsCodeType requiredCode) const
Validate the code of the SDS item.
Definition sds.hh:1701
void ExportDefined(ContainerType *container) const
Export the SDS structure into a buffer, defining any undefined data.
Definition sds.hh:1489
void Export(ContainerType *container) const
Export the SDS structure into a buffer.
Definition sds.hh:1443
void Pointer(T **data, unsigned long *length=0) const
Obtain a pointer to the data area of a primitive SDS item.
Definition sds.hh:1924
virtual SdsCodeType GetCode() const
Return the code of the SDS item.
Definition sds.hh:1679
void ArrayAccess(ArrayAccessHelper< T > *const data, ContainerType *dims) const
Access the data of an SDS primitive item array.
Definition sds.hh:2724
static Id CreateTopLevelArray(const std::string &name, const SdsCodeType code, const unsigned nElem, const std::string &extra="")
Factory constructor method Constructor which creates a new one-dimensional array top-level item.
Definition sds.hh:1124
virtual void List(std::ostream &strm, int lineMaxLen=100) const
List the contents of the structure to an output stream.
Id(const Id &source)=delete
Copy constructor - deleted.
virtual void ShallowCopy(const SdsIdType source, const bool free=false, const bool del=false, const bool readfree=false)
Shallow copy from SdsIdType.
Definition sds.hh:2466
virtual void Delete()
Delete the SDS item.
Definition sds.hh:1378
static Id CreateFromSdsId(const SdsId &item)
Factory constructor method that constructs an sds::Id item from an existing old C++ interface SdsId i...
void GetDims(ContainerType *dims) const
Return the dimensions of the SDS item.
Definition sds.hh:1743
virtual ~Id()
sds::Id Destructor.
Definition sds.hh:1312
virtual void FillArray(const Id &elem)
Fill out the contents of this object, which is a structured array.
Definition sds.hh:1878
virtual SdsIdType COut(const bool outlives, bool *const free=0, bool *const del=0, bool *const readfree=0)
Return this item as an SdsIdType for return to C code.
Definition sds.hh:2361
void ArrayAccess(ArrayAccessHelper< T > *const data, long ndims, ContainerType *dims) const
Access the data of an SDS primitive item array.
Definition sds.hh:2647
virtual void Insert(Id &to_insert)
Insert an SDS object into this object.
Definition sds.hh:1794
virtual Id Index(const long index, bool throwOnNotFound=true) const
Factory constructor method Constructor which returns an id to a structured item indexed by position...
virtual unsigned long Size() const
Return the size of an SDS structure, as required for exporting.
Definition sds.hh:2101
void Get(const unsigned long length, T *const data, unsigned long *actlen=nullptr, const unsigned long offset=0) const
Get data from an SDS item.
Definition sds.hh:1586
static Id CreateArgCmdStructSingle(const T value, const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure in the DRAMA Command style.
Definition sds.hh:3012
void Put(const std::string &value)
Insert a string value into the component.
Definition sds.hh:3263
virtual void Extract()
Extract the SDS structure from its parent.
Definition sds.hh:1522
virtual void PutExtra(const std::string &extra)
Put extra data into an SDS item.
Definition sds.hh:2013
virtual void List(PrintObjectPnt *printer, int lineMaxLen=100) const
List the contents of the structure via a PrintObjectPnt object.
static Id CreateTopLevel(const std::string &name, const SdsCodeType code, const std::string &extra="")
Constructor which creates a new (non-array) top-level item.
virtual Id Copy() const
Factory constructor method Id Copy constructor.
void AddToArgCmdStruct(const ContainerType &values, const unsigned firstArg=1)
Insert a set of values from a container into an SDS structure in in the DRAMA Command style.
Definition sds.hh:3052
static Id CreateFromSdsIdType(const SdsIdType item, const bool free=false, const bool del=false, const bool readfree=false)
Factory constructor method that constructs an sds::Id item from an existing C language SDS id.
virtual void ShallowCopy(Id *source, const bool outlives)
Shallow copy from sds::Id.
Definition sds.hh:2421
void Put(const unsigned long length, const T *const data, const unsigned long offset=0)
Put data into an SDS item.
Definition sds.hh:1980
virtual void Flush()
Flush data modified by pointer.
Definition sds.hh:1548
static Id CreateArgStruct(const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure.
void Get(T *value) const
Fetch primitive value from the component.
Definition sds.hh:3285
static Id CreateArgCmdStruct(const std::initializer_list< T > &values, const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure in the DRAMA Command style.
Definition sds.hh:2976
virtual int GetInt() const
If the SDS item refers to a scalar value, convert it to an integer.
Id()
Default constructor.
Definition sds.hh:611
Id(Id &&source) noexcept
Move copy constructor.
Definition sds.hh:600
Id CreateChildArray(const std::string &name, const SdsCodeType code, const ContainerType &dims, const std::string &extra="") const
Factory constructor method Constructor which creates a new child item which is an multi-dimensional a...
Definition sds.hh:943
std::string GetString() const
If the SDS item refers to a scalar value or a character string, convert it to a string item.
virtual void ShallowCopy(const Id &source)
Shallow copy from a const sds::Id which will outlive this object.
Definition sds.hh:2392
static Id CreateTopLevelArray(const std::string &name, const SdsCodeType code, const ContainerType &dims, const std::string &extra="")
Factory constructor method Constructor which creates a new array top-level item.
Definition sds.hh:1060
void Put(const std::string &name, T value, const std::string &extraData="")
Insert a primitive value into a named component of the structure.
Definition sds.hh:3135
static Id CreateFromSdsIdTypeCopy(const SdsIdType item)
Factory constructor method that constructs an sds::Id item by coping an existing C language SDS id.
static Id CreateNullItem()
Factory constructor method that constructs an null sds::Id item .
virtual bool IsExternal() const
Determine if the SDS structure is external.
Definition sds.hh:2249
virtual std::string toString(int maxlen=200)
Convert the structure to a string.
Definition sds.hh:3084
virtual bool Exists(const std::string &name) const
Determine if a named item exists in a structure.
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
virtual void Print(const std::string &line) const =0
Method invoked to print one line of an SDS listing.
Abstract class which is sub-classed to print SDS item listings.
Definition sds.hh:310
virtual void Print(const std::string &line)=0
Method invoked to print one line of an SDS listing.
Abstract class which is sub-classed to print SDS item listings.
Definition sds.hh:295
#define DramaTHROW_S(status_, format_,...)
Throw a Drama exception with safe string formatting.
Definition exception.hh:108
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:87
DRAMA 2 Exception classes.
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition sds.hh:3484
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1327
void CheckLockTaken(const std::string func, const std::string &file, const int lineNum)
Ensure the current thread has taken the DRAMA task lock.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
DRAMA 2 include file - drama::sds::ArrayAccessHelper Sds class definitions.