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>
453 "ContainerType is NOT an stl container, if a simple index value, maybe you should consider casting to \"unsigned long\"!");
467 "SDS type does not match expected array type");
469 if (
dims->size() == 0)
472 "Attempt to access an array in an SDS structure which is not an array");
474 if (
dims->size() !=
static_cast<unsigned>(
ndims))
477 "SDS Array structure has % dimensions instead of the expected %",
486 void CheckArrayTypeSingleDim(
488 unsigned long *
const nitems)
const {
490 std::vector<unsigned long>
dims;
491 CheckArrayType(code, 1, &
dims);
501 template <
class T>
void SetArrayHelperDataAddr(
502 T *
const data)
const {
567 CleanUp(
"sds::Id move assignment");
570 _flags = std::move(
rhs._flags);
597 _flags.readfree =
false;
629 const bool del =
false,
const bool readfree =
false) :
633 _flags.readfree = readfree;
680 const bool del =
false,
const bool readfree =
false);
761 template <
class ContainerType>
770 std::is_standard_layout<typename ContainerType::value_type>::value,
771 "The value type in the container must be a standard layout type");
776 "Attempt to access data in empty container");
778 Id item(0,
true,
false,
false);
809 template <
class ContainerType>
817 std::is_standard_layout<typename ContainerType::value_type>::value,
818 "The value type in the container must be a standard layout type");
824 "Attempt to access data in empty container");
828 Id item(0,
true,
true,
false);
872 const std::string &name,
874 const std::string &
extra =
"")
const;
890 const std::string &name,
892 const std::string &
extra =
"");
925 template <
class ContainerType>
927 const std::string &name,
930 const std::string &
extra =
"")
const {
938 "ContainerType is NOT an stl container, if a simple index value, maybe you should consider casting to \"unsigned long\"!");
941 Id item(0,
true,
false,
false);
953 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
953 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %", {
…}
1001 const std::string &name,
1003 const unsigned nElem,
1004 const std::string &
extra =
"")
const {
1006 Id item(0,
true,
false,
false);
1013 unsigned long dims[1];
1050 template <
class ContainerType>
1052 const std::string & name,
1055 const std::string &
extra =
""){
1057 Id item(0,
true,
true,
false);
1069 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
1116 const std::string & name,
1118 const unsigned nElem,
1119 const std::string &
extra =
""){
1121 Id item(0,
true,
true,
false);
1128 unsigned long dims[1];
1184 template <
class ContainerType>
1187 Id item(0,
true,
false,
false);
1195 "ContainerType is NOT an stl container, if a simple index value, maybe you should consider casting to \"unsigned long\"!");
1207 "Failed to access SDS array cell - % dimensions, minimum supported 1, maximum supported is %",
1226 item._flags.free =
false;
1232 "Failed to access cell of existing SDS array id");
1272 Id Cell(
unsigned long index,
1274 Id item(0,
true,
false,
false);
1280 unsigned long dims[1] = {index};
1289 item._flags.free =
false;
1297 "Failed to access cell index % of existing SDS array id", index);
1340 virtual Id Find(
const std::string &name,
1390 CleanUp(
"sds::Id destructor");
1399 virtual void SetFree() { _flags.free =
true; }
1405 virtual void SetDelete() { _flags.del =
true; }
1427 _flags.free =
false;
1429 _flags.readfree =
false;
1466 _flags.free =
false;
1485 if (!
Exists(name))
return;
1518 template <
class ContainerType>
1528 std::is_standard_layout<typename ContainerType::value_type>::value,
1529 "The value type in the container must be a standard layout type");
1564 template <
class ContainerType>
1572 std::is_standard_layout<typename ContainerType::value_type>::value ,
1573 "The value type in the container must be a standard layout type");
1610 _flags.readfree =
false;
1624 virtual void Flush() {
1661 template <
typename T>
1664 unsigned long *
actlen =
nullptr,
1665 const unsigned long offset=0)
const {
1673 std::is_standard_layout<T>::value,
1674 "The type T must be a standard layout type");
1696 virtual std::string
GetExtra()
const {
1698 unsigned long length = 0;
1715 "Failed to Get extra data from SDS item");
1728 virtual std::string
GetName()
const {
1736 "Failed to Get Name of SDS item");
1789 "SDS Item % has code %, was expected to have code %",
1818 template <
class ContainerType>
1827 "ContainerType is NOT an stl container!");
1836 "Failed to Get dimensions of SDS item");
1864 "Failed to Get number of SDS items");
1914 template <
class ContainerType>
1924 "ContainerType is NOT an stl container!");
1937 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
2017 template <
typename T>
2027 std::is_standard_layout<T>::value,
2028 "The type T must be a standard layout and type");
2042 *data =
static_cast<T *
>(
tdata);
2073 template <
typename T>
2075 const T *
const data,
2076 const unsigned long offset=0) {
2084 std::is_standard_layout<T>::value,
2085 "The type T must be a standard layout type");
2087 const void *
tdata =
static_cast<const void *
>(data);
2122 virtual void Rename(
const std::string &name) {
2155 template <
class ContainerType>
2164 "ContainerType is NOT an stl container!");
2177 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
2203 virtual unsigned long Size()
const {
2204 unsigned long bytes;
2226 unsigned long bytes;
2239 virtual void List()
const {
2269 virtual void List(std::ostream &
strm,
2336 "Failed to write SDS structure to file \"%\"",
2376 "Failed to get SDS external structure address");
2397 virtual bool Exists(
const std::string &name)
const;
2411 virtual bool Exists(
unsigned index)
const;
2425 explicit operator SdsIdType()
const {
return _id; }
2432 explicit operator bool()
const {
2464 bool *
const del= 0,
bool *
const readfree = 0) {
2466 *free = _flags.free;
2470 *readfree = _flags.readfree;
2472 _flags.free = _flags.del = _flags.readfree =
false;
2497 CleanUp(
"sds::Id::ShallowCopy 1");
2499 _flags.free = _flags.del = _flags.readfree =
false;
2526 CleanUp(
"sds::Id::ShallowCopy 2");
2534 _flags.free =
source->_flags.free;
2535 _flags.del =
source->_flags.del;
2536 _flags.readfree =
source->_flags.readfree;
2539 source->_flags.readfree =
false;
2543 _flags.free = _flags.del = _flags.readfree =
false;
2569 const bool del =
false,
const bool readfree =
false) {
2570 CleanUp(
"sds::Id::ShallowCopy 3");
2573 _flags.readfree = readfree;
2596 _flags.del, _flags.readfree);
2597 _flags.free =
false;
2599 _flags.readfree =
false;
2606 target->ShallowCopy(_id);
2650 CheckArrayTypeSingleDim(data->Code(),
dims);
2651 data->SetNumElements(
dims[0]);
2652 SetArrayHelperDataAddr(data);
2691 const unsigned long nitems,
2692 sds::ArrayAccessHelper<T> *
const data)
const {
2695 CheckArrayTypeSingleDim(data->Code(),
dims);
2699 "ArrayAccess expected % items, found %",
2702 data->SetNumElements(
dims[0]);
2703 SetArrayHelperDataAddr(data);
2749 template <
typename T,
class ContainerType>
void ArrayAccess(
2759 "Failed to access SDS array. Numbers of dimensions % invalid, must be in range 1 to %",
2763 CheckArrayType(data->Code(),
ndims,
dims);
2768 unsigned long elements = (*dims)[0];
2769 for (
unsigned long i = 1;
i <
dims->size() ; ++
i)
2773 data->SetNumElements(elements);
2777 SetArrayHelperDataAddr(data);
2826 template <
typename T,
class ContainerType>
void ArrayAccess(
2885 const std::string &name,
2888 const std::string &
extra =
"") {
2892 data->SetNumElements(
nitems);
2893 arrayId.SetArrayHelperDataAddr(data);
2950 const std::string &name,
2952 sds::ArrayWriteHelper<T> *
const data,
2953 const std::string &
extra =
"") {
2960 unsigned long elements =
dims[0];
2961 for (
unsigned long i = 1;
i <
dims.size() ; ++
i)
2966 data->SetNumElements(elements);
2967 arrayId.SetArrayHelperDataAddr(data);
3021 template <
typename ContainerType>
3024 const std::string &name=
"ArgStructure") {
3077 template <
typename T>
3079 const std::initializer_list<T> &
values,
3080 const std::string &name=
"ArgStructure") {
3113 template <
typename T>
3116 const std::string &name=
"ArgStructure") {
3153 template <
typename ContainerType>
3192 char *
string =
new char[
maxlen];
3205 std::string
result=&
string[0];
3236 template <
typename T>
3249 "ArgPut failed of item \"%\" failed",
3270 void Put (
const std::string &name,
const std::string &
value,
3278 "ArgPut failed of item \"%\" failed",
3306 template <
typename T>
3307 void Get (
const std::string &name, T *
value)
const {
3319 "ArgGet failed of item \"%\" failed",
3342 template <
typename T>
3365 void Put (
const std::string &
value) {
3386 template <
typename T>
3424 template <
class ContainerType>
3440 "Failed to check SDS array - % dimensions, minimum supported 0, maximum supported is %",
3464 virtual int GetInt()
const;
3470 virtual unsigned int GetUInt()
const;
3483 virtual unsigned long GetULong()
const;
3508 nullptr,
nullptr,
nullptr, &
status);
3528 std::string _function;
3551 : _line(
line), _file(
file), _function(function) {
3565 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);
3567 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);
3581#define SDS_CHECK_IDS2(function_) drama::sds:IdChecker _sds_id_checker(__LINE__, __FILE__, (function_))
3586 typedef std::shared_ptr<Id>
IdPtr;
3597 void operator()(
void *)
const { }
3618 template <
typename T>
3619 class DataPointer :
public std::unique_ptr<T,_nodel> {
3622 unsigned long _lengthBytes;
3640 std::is_standard_layout<T>::value,
3641 "The type T must be a standard layout and type");
3646 if (_lengthBytes !=
sizeof(T))
3649 "SDS Pointer error - expected % bytes, got %",
3650 sizeof(T), _lengthBytes);
3655 std::unique_ptr<T, _nodel>
p(
dataPnt, _nodel());
3657 *((std::unique_ptr<T,_nodel>*)(
this)) = std::move(
p);
3679 std::is_standard_layout<T>::value,
3680 "The type T must be a standard layout type");
3685 if (_lengthBytes !=
sizeof(T))
3688 "SDS Pointer error - expected % bytes, got %",
3689 sizeof(T), _lengthBytes);
3694 std::unique_ptr<T, _nodel>
p(
dataPnt, _nodel());
3696 *((std::unique_ptr<T,_nodel>*)(
this)) = std::move(
p);
3721 return _lengthBytes;
3744 template <
typename T>
3745 class DataPointer<T[]> :
public std::unique_ptr<T[], _nodel> {
3748 unsigned long _numItems;
3749 unsigned long _lengthBytes;
3646 if (_lengthBytes !=
sizeof(T)) {
…};
3753 typedef T * iterator;
3755 typedef const T * const_iterator;
3757 typedef T value_type;
3777 std::is_standard_layout<T>::value,
3778 "The type T must be a standard layout type");
3783 if (_lengthBytes <
sizeof(T))
3786 "SDS Array Pointer error - expected at least % bytes, got %",
3787 sizeof(T), _lengthBytes);
3792 _numItems = _lengthBytes/
sizeof(
dataPnt[0]);
3797 *((std::unique_ptr<T[],_nodel>*)(
this)) = std::move(
p);
3820 std::is_standard_layout<T>::value,
3821 "The type T must be a standard layout type");
3826 if (_lengthBytes <
sizeof(T))
3829 "SDS Array Pointer error - expected at least % bytes, got %",
3830 sizeof(T), _lengthBytes);
3835 _numItems = _lengthBytes/
sizeof(
dataPnt[0]);
3840 *((std::unique_ptr<T[],_nodel>*)(
this)) = std::move(
p);
3863 unsigned long size()
const {
3871 return _lengthBytes;
3878 return & (*this)[0];
3885 return (&(*
this)[0])+_numItems;
3891 const_iterator begin()
const {
3892 return & (*this)[0];
3898 const_iterator end()
const {
3899 return (&(*
this)[0])+_numItems;
3908 const_iterator cbegin()
const {
3909 return & (*this)[0];
3919 return (&(*
this)[0])+_numItems;
3932 bool empty()
const {
3979 using iterator_category = std::forward_iterator_tag;
3980 using value_type =
Id;
3981 using difference_type =std::ptrdiff_t;
3982 using pointer =
Id*;
3983 using reference =
Id&;
3991 bool _isArray =
false;
4016 "Attempt to construct IdIterator on non-structured SDS item (code %)", _top.
GetCode());
4022 std::vector<unsigned>
dims;
4024 if (
dims.size() > 0)
4038 "Attempt to construct IdIterator on an array of structures with more then 1 dimension - can't yet do that. ");
4044 _endCell =
dims[0]+1;
4053 _endCell =
id.GetNumItems()+1;
4060 _curCell = _endCell;
4072 if (&_top != &
other._top)
4074 return _curCell !=
other._curCell;
4083 if (_curCell >= _endCell)
4086 "Attempt to dereference IdIterator past end of structure");
4091 std::vector<unsigned long>
indicies(1);
4095 return _top.
Index(_curCell);
4110 if (_curCell < _endCell)
4139 template <
typename T>
4140 class ArrayContainer {
4149 T *_address =
nullptr;
4161 std::is_standard_layout<T>::value,
4162 "The type T must be a standard layout and type");
4168 bool empty()
const {
4169 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:4202
reference operator[](size_type n)
Returns an item at a particular address.
Definition sds.hh:4210
bool empty() const
Returns true if the container is empty.
Definition sds.hh:4195
value_type & reference
The type for a reference to the value.
Definition sds.hh:4172
T value_type
The value type.
Definition sds.hh:4170
ArrayContainer(T *address, size_type size)
Create a container to access the array.
Definition sds.hh:4185
std::size_t size_type
The type used for sizes.
Definition sds.hh:4174
~ArrayContainer()
Destroy the container, not the underlying array item.
Definition sds.hh:4215
A container for simple arrays for use with SDS templates.
Definition sds.hh:4167
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:3945
iterator begin()
Returns an iterator pointing to the first element in the array.
Definition sds.hh:3904
const_iterator cbegin() const
Returns a const iterator pointing to the first element in the array.
Definition sds.hh:3935
bool empty() const
Returns true if container is empty.
Definition sds.hh:3959
const T * const_iterator
const iterator for this item
Definition sds.hh:3782
iterator end()
Returns an iterator pointing to the past-the-end element in the array.
Definition sds.hh:3911
unsigned long size() const
Return the number of elements in the array.
Definition sds.hh:3890
DataPointer(const drama::sds::Id &theId)
DataPointer Constructor.
Definition sds.hh:3795
const_iterator begin() const
Returns a const iterator pointing to the first element in the array.
Definition sds.hh:3918
unsigned long NumBytes() const
Return the size of the item in bytes.
Definition sds.hh:3897
~DataPointer()
DataPointer destructor.
Definition sds.hh:3877
T * iterator
iterator for this item
Definition sds.hh:3780
T value_type
Returns the type of T
Definition sds.hh:3784
DataPointer(drama::sds::Id *theId, bool outlives=false)
DataPointer Constructor.
Definition sds.hh:3838
const_iterator end() const
Returns a const iterator pointing to the past-the-end element in the array.
Definition sds.hh:3925
unsigned long NumBytes() const
Return the size of the item in bytes.
Definition sds.hh:3747
DataPointer(drama::sds::Id *theId, bool outlives)
DataPointer Constructor.
Definition sds.hh:3697
~DataPointer()
DataPointer destructor.
Definition sds.hh:3734
DataPointer(const drama::sds::Id &theId)
DataPointer Constructor.
Definition sds.hh:3659
A class that provides direct access to the data of an SDS item, via a sub-class of std::unique_ptr<>.
Definition sds.hh:3646
IdChecker(int line, const char *file, const char *function)
Construct an SdsChecker object.
Definition sds.hh:3577
virtual ~IdChecker()
SdsCheck destructor.
Definition sds.hh:3588
A class to check for SDS leaks.
Definition sds.hh:3550
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:4035
bool operator!=(const IdIterator &other) const
Inequality operator.
Definition sds.hh:4097
Id operator*() const
Dereference operator - return the sds::Id item the iterator is pointing to.
Definition sds.hh:4109
const IdIterator & operator++()
Increment operator (prefix version).
Definition sds.hh:4131
An iterator for working through SDS Structures and SDS arrays of structures.
Definition sds.hh:4004
virtual void SetFree()
Indicate the underlying SDS item should be free-ed when the sds::Id object is destroyed.
Definition sds.hh:1426
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:1027
Id & operator=(Id &&rhs) noexcept
Move assignment operator.
Definition sds.hh:591
virtual std::string GetName() const
Return the name of the SDS item.
Definition sds.hh:1755
virtual std::string GetExtra() const
Get extra data from an SDS item.
Definition sds.hh:1723
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:2183
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:2911
void Get(const std::string &name, T *value) const
Fetch primitive value from a named component of the structure.
Definition sds.hh:3334
virtual void ClearDelete()
Indicate the underlying SDS structure should NOT be deleted when the sds::Id object is destroyed.
Definition sds.hh:1442
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:3452
unsigned GetNumItems() const
Return the number of components in an SDS structure.
Definition sds.hh:1884
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:1453
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:2717
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:2673
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:3049
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:1432
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:789
virtual unsigned long SizeDefined() const
Return the size of an SDS structure, as required for exporting when fully defined.
Definition sds.hh:2252
virtual void Write(const std::string &filename) const
Write the contents of the structure to a file.
Definition sds.hh:2358
virtual void Rename(const std::string &name)
Rename the SDS item.
Definition sds.hh:2149
virtual void List() const
List the contents of the structure to standard output.
Definition sds.hh:2266
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:3297
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:1510
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:2976
void Put(T value)
Insert a primitive value into the item.
Definition sds.hh:3370
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:1942
Id Cell(const ContainerType &indicies, bool throwOnNotFound=true) const
Factory constructor method Constructor that returns a cell of a SDS structure which must be an array ...
Definition sds.hh:1212
Id Cell(unsigned long index, bool throwOnNotFound=true) const
Factory constructor method Constructor that returns a cell of a SDS structure which must be a single ...
Definition sds.hh:1299
virtual void ToSdsId(::SdsId *target, const bool outlives=false)
Shallow copy to an SdsId type.
Definition sds.hh:2615
static Id CreateByImport(const ContainerType &container)
Factory constructor method that imports an exported SDS structure found in a byte stream.
Definition sds.hh:837
virtual void List(FILE *to) const
List the contents of the structure to a C file.
Definition sds.hh:2278
virtual void ValidateCode(SdsCodeType requiredCode) const
Validate the code of the SDS item.
Definition sds.hh:1804
void ExportDefined(ContainerType *container) const
Export the SDS structure into a buffer, defining any undefined data.
Definition sds.hh:1592
void Export(ContainerType *container) const
Export the SDS structure into a buffer.
Definition sds.hh:1546
void Pointer(T **data, unsigned long *length=0) const
Obtain a pointer to the data area of a primitive SDS item.
Definition sds.hh:2045
virtual SdsCodeType GetCode() const
Return the code of the SDS item.
Definition sds.hh:1782
void ArrayAccess(ArrayAccessHelper< T > *const data, ContainerType *dims) const
Access the data of an SDS primitive item array.
Definition sds.hh:2853
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:1142
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:2595
virtual void Delete()
Delete the SDS item.
Definition sds.hh:1481
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:1846
virtual ~Id()
sds::Id Destructor.
Definition sds.hh:1415
virtual void FillArray(const Id &elem)
Fill out the contents of this object, which is a structured array.
Definition sds.hh:1999
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:2490
void ArrayAccess(ArrayAccessHelper< T > *const data, long ndims, ContainerType *dims) const
Access the data of an SDS primitive item array.
Definition sds.hh:2776
virtual void Insert(Id &to_insert)
Insert an SDS object into this object.
Definition sds.hh:1906
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:2230
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:1689
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:3141
void Put(const std::string &value)
Insert a string value into the component.
Definition sds.hh:3392
virtual void Extract()
Extract the SDS structure from its parent.
Definition sds.hh:1625
virtual void PutExtra(const std::string &extra)
Put extra data into an SDS item.
Definition sds.hh:2134
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:3181
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:2550
void Put(const unsigned long length, const T *const data, const unsigned long offset=0)
Put data into an SDS item.
Definition sds.hh:2101
virtual void Flush()
Flush data modified by pointer.
Definition sds.hh:1651
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:3414
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:3105
virtual int GetInt() const
If the SDS item refers to a scalar value, convert it to an integer.
Id()
Default constructor.
Definition sds.hh:620
Id(Id &&source) noexcept
Move copy constructor.
Definition sds.hh:609
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:953
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:2521
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:1078
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:3264
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:2378
virtual std::string toString(int maxlen=200)
Convert the structure to a string.
Definition sds.hh:3213
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:3613
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.