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>
762 (std::is_standard_layout<typename ContainerType::value_type>::value &&
763 std::is_trivial<typename ContainerType::value_type>::value) ,
764 "The value type in the container must be a standard layout and trivial (POD) type");
769 "Attempt to access data in empty container");
771 Id item(0,
true,
false,
false);
802 template <
class ContainerType>
810 (std::is_standard_layout<typename ContainerType::value_type>::value &&
811 std::is_trivial<typename ContainerType::value_type>::value ) ,
812 "The value type in the container must be a standard layout and trivial (POD) type");
818 "Attempt to access data in empty container");
822 Id item(0,
true,
true,
false);
866 const std::string &name,
868 const std::string &
extra =
"")
const;
884 const std::string &name,
886 const std::string &
extra =
"");
912 template <
class ContainerType>
914 const std::string &name,
917 const std::string &
extra =
"")
const {
919 Id item(0,
true,
false,
false);
931 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
973 const std::string &name,
975 const unsigned nElem,
976 const std::string &
extra =
"")
const {
978 Id item(0,
true,
false,
false);
985 unsigned long dims[1];
1015 template <
class ContainerType>
1017 const std::string & name,
1020 const std::string &
extra =
""){
1022 Id item(0,
true,
true,
false);
1034 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
1075 const std::string & name,
1077 const unsigned nElem,
1078 const std::string &
extra =
""){
1080 Id item(0,
true,
true,
false);
1087 unsigned long dims[1];
1134 template <
class ContainerType>
1137 Id item(0,
true,
false,
false);
1148 "Failed to access SDS array cell - % dimensions, minimum supported 1, maximum supported is %",
1167 item._flags.del =
false;
1173 "Failed to access cell of existing SDS array id");
1214 virtual Id Find(
const std::string &name,
1264 CleanUp(
"sds::Id destructor");
1273 virtual void SetFree() { _flags.free =
true; }
1279 virtual void SetDelete() { _flags.del =
true; }
1301 _flags.free =
false;
1303 _flags.readfree =
false;
1340 _flags.free =
false;
1374 template <
class ContainerType>
1384 (std::is_standard_layout<typename ContainerType::value_type>::value &&
1385 std::is_trivial<typename ContainerType::value_type>::value) ,
1386 "The value type in the container must be a standard layout and trivial (POD) type");
1421 template <
class ContainerType>
1429 (std::is_standard_layout<typename ContainerType::value_type>::value &&
1430 std::is_trivial<typename ContainerType::value_type>::value) ,
1431 "The value type in the container must be a standard layout and trivial (POD) type");
1468 _flags.readfree =
false;
1482 virtual void Flush() {
1519 template <
typename T>
1522 unsigned long *
actlen =
nullptr,
1523 const unsigned long offset=0)
const {
1531 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
1532 "The type T must be a standard layout and trivial (POD) type");
1555 virtual std::string
GetExtra()
const {
1557 unsigned long length = 0;
1574 "Failed to Get extra data from SDS item");
1587 virtual std::string
GetName()
const {
1595 "Failed to Get Name of SDS item");
1648 "SDS Item % has code %, was expected to have code %",
1677 template <
class ContainerType>
1686 "Failed to Get dimensions of SDS item");
1714 "Failed to Get number of SDS items");
1764 template <
class ContainerType>
1778 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
1858 template <
typename T>
1868 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
1869 "The type T must be a standard layout and trivial (POD) type");
1883 *data =
static_cast<T *
>(
tdata);
1914 template <
typename T>
1916 const T *
const data,
1917 const unsigned long offset=0) {
1925 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
1926 "The type T must be a standard layout and trivial (POD) type");
1928 const void *
tdata =
static_cast<const void *
>(data);
1963 virtual void Rename(
const std::string &name) {
1996 template <
class ContainerType>
2010 "Failed to create new SDS array - % dimensions, minimum supported 1, maximum supported is %",
2036 virtual unsigned long Size()
const {
2037 unsigned long bytes;
2059 unsigned long bytes;
2072 virtual void List()
const {
2102 virtual void List(std::ostream &
strm,
2169 "Failed to write SDS structure to file \"%\"",
2209 "Failed to get SDS external structure address");
2230 virtual bool Exists(
const std::string &name)
const;
2244 virtual bool Exists(
unsigned index)
const;
2258 explicit operator SdsIdType()
const {
return _id; }
2265 explicit operator bool()
const {
2297 bool *
const del= 0,
bool *
const readfree = 0) {
2299 *free = _flags.free;
2303 *readfree = _flags.readfree;
2305 _flags.free = _flags.del = _flags.readfree =
false;
2330 CleanUp(
"sds::Id::ShallowCopy 1");
2332 _flags.free = _flags.del = _flags.readfree =
false;
2359 CleanUp(
"sds::Id::ShallowCopy 2");
2367 _flags.free =
source->_flags.free;
2368 _flags.del =
source->_flags.del;
2369 _flags.readfree =
source->_flags.readfree;
2372 source->_flags.readfree =
false;
2376 _flags.free = _flags.del = _flags.readfree =
false;
2402 const bool del =
false,
const bool readfree =
false) {
2403 CleanUp(
"sds::Id::ShallowCopy 3");
2406 _flags.readfree = readfree;
2429 _flags.del, _flags.readfree);
2430 _flags.free =
false;
2432 _flags.readfree =
false;
2439 target->ShallowCopy(_id);
2483 CheckArrayTypeSingleDim(data->Code(),
dims);
2484 data->SetNumElements(
dims[0]);
2485 SetArrayHelperDataAddr(data);
2524 const unsigned long nitems,
2525 sds::ArrayAccessHelper<T> *
const data)
const {
2528 CheckArrayTypeSingleDim(data->Code(),
dims);
2532 "ArrayAccess expected % items, found %",
2535 data->SetNumElements(
dims[0]);
2536 SetArrayHelperDataAddr(data);
2582 template <
typename T,
class ContainerType>
void ArrayAccess(
2592 "Failed to access SDS array. Numbers of dimensions % invalid, must be in range 1 to %",
2596 CheckArrayType(data->Code(),
ndims,
dims);
2601 unsigned long elements = (*dims)[0];
2602 for (
unsigned long i = 1;
i <
dims->size() ; ++
i)
2606 data->SetNumElements(elements);
2610 SetArrayHelperDataAddr(data);
2660 template <
typename T,
class ContainerType>
void ArrayAccess(
2726 template <
typename ContainerType>
2729 const std::string &name=
"ArgStructure") {
2782 template <
typename T>
2784 const std::initializer_list<T> &
values,
2785 const std::string &name=
"ArgStructure") {
2818 template <
typename T>
2821 const std::string &name=
"ArgStructure") {
2858 template <
typename ContainerType>
2897 char *
string =
new char[
maxlen];
2910 std::string
result=&
string[0];
2941 template <
typename T>
2954 "ArgPut failed of item \"%\" failed",
2975 void Put (
const std::string &name,
const std::string &
value,
2983 "ArgPut failed of item \"%\" failed",
3011 template <
typename T>
3012 void Get (
const std::string &name, T *
value)
const {
3024 "ArgGet failed of item \"%\" failed",
3047 template <
typename T>
3070 void Put (
const std::string &
value) {
3091 template <
typename T>
3129 template <
class ContainerType>
3145 "Failed to check SDS array - % dimensions, minimum supported 0, maximum supported is %",
3169 virtual int GetInt()
const;
3175 virtual unsigned int GetUInt()
const;
3188 virtual unsigned long GetULong()
const;
3213 nullptr,
nullptr,
nullptr, &
status);
3233 std::string _function;
3256 : _line(
line), _file(
file), _function(function) {
3270 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);
3272 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);
3286#define SDS_CHECK_IDS2(function_) drama::sds:IdChecker _sds_id_checker(__LINE__, __FILE__, (function_))
3291 typedef std::shared_ptr<Id>
IdPtr;
3302 void operator()(
void *)
const { }
3323 template <
typename T>
3324 class DataPointer :
public std::unique_ptr<T,_nodel> {
3327 unsigned long _lengthBytes;
3345 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
3346 "The type T must be a standard layout and trivial (POD) type");
3351 if (_lengthBytes !=
sizeof(T))
3354 "SDS Pointer error - expected % bytes, got %",
3355 sizeof(T), _lengthBytes);
3360 std::unique_ptr<T, _nodel>
p(
dataPnt, _nodel());
3362 *((std::unique_ptr<T,_nodel>*)(
this)) = std::move(
p);
3384 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
3385 "The type T must be a standard layout and trivial (POD) type");
3390 if (_lengthBytes !=
sizeof(T))
3393 "SDS Pointer error - expected % bytes, got %",
3394 sizeof(T), _lengthBytes);
3399 std::unique_ptr<T, _nodel>
p(
dataPnt, _nodel());
3401 *((std::unique_ptr<T,_nodel>*)(
this)) = std::move(
p);
3426 return _lengthBytes;
3449 template <
typename T>
3450 class DataPointer<T[]> :
public std::unique_ptr<T[], _nodel> {
3456 unsigned long _numItems;
3457 unsigned long _lengthBytes;
3461 typedef T * iterator;
3463 typedef const T * const_iterator;
3465 typedef T value_type;
3485 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
3486 "The type T must be a standard layout and trivial (POD) type");
3491 if (_lengthBytes <
sizeof(T))
3494 "SDS Array Pointer error - expected at least % bytes, got %",
3495 sizeof(T), _lengthBytes);
3500 _numItems = _lengthBytes/
sizeof(
dataPnt[0]);
3505 *((std::unique_ptr<T[],_nodel>*)(
this)) = std::move(
p);
3528 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
3529 "The type T must be a standard layout and trivial (POD) type");
3534 if (_lengthBytes <
sizeof(T))
3537 "SDS Array Pointer error - expected at least % bytes, got %",
3538 sizeof(T), _lengthBytes);
3543 _numItems = _lengthBytes/
sizeof(
dataPnt[0]);
3548 *((std::unique_ptr<T[],_nodel>*)(
this)) = std::move(
p);
3571 unsigned long size()
const {
3579 return _lengthBytes;
3586 return & (*this)[0];
3593 return (&(*
this)[0])+_numItems;
3599 const_iterator begin()
const {
3600 return & (*this)[0];
3606 const_iterator end()
const {
3607 return (&(*
this)[0])+_numItems;
3616 const_iterator cbegin()
const {
3617 return & (*this)[0];
3627 return (&(*
this)[0])+_numItems;
3640 bool empty()
const {
3687 using iterator_category = std::forward_iterator_tag;
3688 using value_type =
Id;
3689 using difference_type =std::ptrdiff_t;
3690 using pointer =
Id*;
3691 using reference =
Id&;
3699 bool _isArray =
false;
3724 "Attempt to construct IdIterator on non-structured SDS item (code %)", _top.
GetCode());
3730 std::vector<unsigned>
dims;
3732 if (
dims.size() > 0)
3746 "Attempt to construct IdIterator on an array of structures with more then 1 dimension - can't yet do that. ");
3752 _endCell =
dims[0]+1;
3761 _endCell =
id.GetNumItems()+1;
3768 _curCell = _endCell;
3780 if (&_top != &
other._top)
3782 return _curCell !=
other._curCell;
3791 if (_curCell >= _endCell)
3794 "Attempt to dereference IdIterator past end of structure");
3799 std::vector<unsigned long>
indicies(1);
3803 return _top.
Index(_curCell);
3818 if (_curCell < _endCell)
3847 template <
typename T>
3848 class ArrayContainer {
3857 T *_address =
nullptr;
3869 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
3870 "The type T must be a standard layout and trivial (POD) type");
3876 bool empty()
const {
3877 return (_size <= 0);
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:3910
reference operator[](size_type n)
Returns an item at a particular address.
Definition sds.hh:3918
bool empty() const
Returns true if the container is empty.
Definition sds.hh:3903
value_type & reference
The type for a reference to the value.
Definition sds.hh:3880
T value_type
The value type.
Definition sds.hh:3878
ArrayContainer(T *address, size_type size)
Create a container to access the array.
Definition sds.hh:3893
std::size_t size_type
The type used for sizes.
Definition sds.hh:3882
~ArrayContainer()
Destroy the container, not the underlying array item.
Definition sds.hh:3923
A container for simple arrays for use with SDS templates.
Definition sds.hh:3875
const_iterator cend() const
Returns a const iterator pointing to the past-the-end element in the array.
Definition sds.hh:3653
iterator begin()
Returns an iterator pointing to the first element in the array.
Definition sds.hh:3612
const_iterator cbegin() const
Returns a const iterator pointing to the first element in the array.
Definition sds.hh:3643
bool empty() const
Returns true if container is empty.
Definition sds.hh:3667
const T * const_iterator
const iterator for this item
Definition sds.hh:3490
iterator end()
Returns an iterator pointing to the past-the-end element in the array.
Definition sds.hh:3619
unsigned long size() const
Return the number of elements in the array.
Definition sds.hh:3598
DataPointer(const drama::sds::Id &theId)
DataPointer Constructor.
Definition sds.hh:3503
const_iterator begin() const
Returns a const iterator pointing to the first element in the array.
Definition sds.hh:3626
unsigned long NumBytes() const
Return the size of the item in bytes.
Definition sds.hh:3605
~DataPointer()
DataPointer destructor.
Definition sds.hh:3585
T * iterator
iterator for this item
Definition sds.hh:3488
T value_type
Returns the type of T
Definition sds.hh:3492
DataPointer(drama::sds::Id *theId, bool outlives=false)
DataPointer Constructor.
Definition sds.hh:3546
const_iterator end() const
Returns a const iterator pointing to the past-the-end element in the array.
Definition sds.hh:3633
unsigned long NumBytes() const
Return the size of the item in bytes.
Definition sds.hh:3452
DataPointer(drama::sds::Id *theId, bool outlives)
DataPointer Constructor.
Definition sds.hh:3402
~DataPointer()
DataPointer destructor.
Definition sds.hh:3439
DataPointer(const drama::sds::Id &theId)
DataPointer Constructor.
Definition sds.hh:3364
A class that provides direct access to the data of an SDS item, via a sub-class of std::unique_ptr<>.
Definition sds.hh:3351
IdChecker(int line, const char *file, const char *function)
Construct an SdsChecker object.
Definition sds.hh:3282
virtual ~IdChecker()
SdsCheck destructor.
Definition sds.hh:3293
A class to check for SDS leaks.
Definition sds.hh:3255
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:3743
bool operator!=(const IdIterator &other) const
Inequality operator.
Definition sds.hh:3805
Id operator*() const
Dereference operator - return the sds::Id item the iterator is pointing to.
Definition sds.hh:3817
const IdIterator & operator++()
Increment operator (prefix version).
Definition sds.hh:3839
An iterator for working through SDS Structures and SDS arrays of structures.
Definition sds.hh:3712
virtual void SetFree()
Indicate the underlying SDS item should be free-ed when the sds::Id object is destroyed.
Definition sds.hh:1300
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:999
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:1614
virtual std::string GetExtra() const
Get extra data from an SDS item.
Definition sds.hh:1582
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:2024
static Id FromFile(const std::string &filename)
Factory constructor method that reads an SDS structure from a file.
void Get(const std::string &name, T *value) const
Fetch primitive value from a named component of the structure.
Definition sds.hh:3039
virtual void ClearDelete()
Indicate the underlying SDS structure should NOT be deleted when the sds::Id object is destroyed.
Definition sds.hh:1316
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:3157
unsigned GetNumItems() const
Return the number of components in an SDS structure.
Definition sds.hh:1734
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:1327
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:2550
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:2506
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:2754
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:1306
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:2085
virtual void Write(const std::string &filename) const
Write the contents of the structure to a file.
Definition sds.hh:2191
virtual void Rename(const std::string &name)
Rename the SDS item.
Definition sds.hh:1990
virtual void List() const
List the contents of the structure to standard output.
Definition sds.hh:2099
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:3002
static Id CreateFromSdsId(SdsId *item)
Factory constructor method that constructs an sds::Id item from an existing old C++ interface SdsId i...
virtual unsigned int GetUInt() const
If the SDS item refers to a scalar value, convert it to an unsigned integer.
void Put(T value)
Insert a primitive value into the item.
Definition sds.hh:3075
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:1792
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:1162
virtual void ToSdsId(::SdsId *target, const bool outlives=false)
Shallow copy to an SdsId type.
Definition sds.hh:2448
static Id CreateByImport(const ContainerType &container)
Factory constructor method that imports an exported SDS structure found in a byte stream.
Definition sds.hh:830
virtual void List(FILE *to) const
List the contents of the structure to a C file.
Definition sds.hh:2111
virtual void ValidateCode(SdsCodeType requiredCode) const
Validate the code of the SDS item.
Definition sds.hh:1663
void ExportDefined(ContainerType *container) const
Export the SDS structure into a buffer, defining any undefined data.
Definition sds.hh:1449
void Export(ContainerType *container) const
Export the SDS structure into a buffer.
Definition sds.hh:1402
void Pointer(T **data, unsigned long *length=0) const
Obtain a pointer to the data area of a primitive SDS item.
Definition sds.hh:1886
virtual SdsCodeType GetCode() const
Return the code of the SDS item.
Definition sds.hh:1641
void ArrayAccess(ArrayAccessHelper< T > *const data, ContainerType *dims) const
Access the data of an SDS primitive item array.
Definition sds.hh:2687
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:1101
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:2428
virtual void Delete()
Delete the SDS item.
Definition sds.hh:1355
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:1705
virtual ~Id()
sds::Id Destructor.
Definition sds.hh:1289
virtual void FillArray(const Id &elem)
Fill out the contents of this object, which is a structured array.
Definition sds.hh:1840
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:2323
void ArrayAccess(ArrayAccessHelper< T > *const data, long ndims, ContainerType *dims) const
Access the data of an SDS primitive item array.
Definition sds.hh:2609
virtual void Insert(Id &to_insert)
Insert an SDS object into this object.
Definition sds.hh:1756
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:2063
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:1547
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:2846
void Put(const std::string &value)
Insert a string value into the component.
Definition sds.hh:3097
virtual void Extract()
Extract the SDS structure from its parent.
Definition sds.hh:1483
virtual void PutExtra(const std::string &extra)
Put extra data into an SDS item.
Definition sds.hh:1975
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:2886
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:2383
void Put(const unsigned long length, const T *const data, const unsigned long offset=0)
Put data into an SDS item.
Definition sds.hh:1942
virtual void Flush()
Flush data modified by pointer.
Definition sds.hh:1509
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:3119
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:2810
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:940
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:2354
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:1043
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:2969
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:2211
virtual std::string toString(int maxlen=200)
Convert the structure to a string.
Definition sds.hh:2918
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:110
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:93
DRAMA 2 Exception classes.
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition sds.hh:3318
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
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.