static const char *rcsId="@(#) $Id$";
static void *use_rcsId = (0 ? (void *)(&use_rcsId) : (void *) &rcsId);
#include "drama.h"
#include "mess.h"
#include "sds_err_msgt.h"
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <unistd.h>
int main(int , const char *[])
{
MessPutFacility(&MessFac_SDS);
try
{
Construct(&topLevel);
topLevel.
Write(
"argtest.sds");
Examine(topLevel);
Examine(topLevel2);
topLevel2 = topLevel.
Copy();
}
{
return 1;
}
unlink("argtest.sds");
return 0;
}
{
topLevel->
Put(
"BoolItem",
true);
topLevel->
Put(
"SimpleIntItem", 2);
topLevel->
Put(
"CharItem", (
char)(3));
topLevel->
Put(
"ShortItem", (
short)(4));
topLevel->
Put(
"UShortItem", (
unsigned short)(5));
topLevel->
Put(
"INT32Item", (INT32)(6));
topLevel->
Put(
"UINT32Item", (UINT32)(7));
topLevel->
Put(
"INT64Item", (INT64)(8));
topLevel->
Put(
"UINT64Item", (UINT64)(9));
topLevel->
Put(
"FloatItem", (
float)(10));
topLevel->
Put(
"DoubleItem", (
double)(11));
topLevel->
Put(
"StringItem1",
"12");
std::string test13("13");
topLevel->
Put(
"StringItem2", test13);
}
template <typename T>
void CheckItem(
const std::string &name,
T expectedValue)
{
T actualValue;
top.
Get(name, &actualValue);
if (actualValue != expectedValue)
{
std::cerr << "Failed to fetch correct value from item \""
<< name
<< "\""
<< std::endl
<< " Expected \""
<< expectedValue
<< "\" Got \""
<< actualValue
<< "\""
<< std::endl;
return;
}
}
{
CheckItem(topLevel, "BoolItem", true);
CheckItem(topLevel, "SimpleIntItem", 2);
CheckItem(topLevel, "CharItem", (char)(3));
CheckItem(topLevel, "ShortItem", (short)(4));
CheckItem(topLevel, "UShortItem", (unsigned short)(5));
CheckItem(topLevel, "INT32Item", (INT32)(6));
CheckItem(topLevel, "UINT32Item", (UINT32)(7));
CheckItem(topLevel, "INT64Item", (INT64)(8));
CheckItem(topLevel, "UINT64Item", (UINT64)(9));
CheckItem(topLevel, "FloatItem", (float)(10));
CheckItem(topLevel, "DoubleItem", (double)(11));
CheckItem(topLevel, "StringItem1", std::string("12"));
CheckItem(topLevel, "StringItem2", std::string("13"));
}
virtual void Print(FILE *file=stderr, bool include_stacktrace=false) const
Print exception details to a file.
An Exception class for exceptions thrown by DRAMA V2 classes.
Definition exception.hh:164
static Id FromFile(const std::string &filename)
Factory constructor method that reads an SDS structure from a file.
virtual void Write(const std::string &filename) const
Write the contents of the structure to a file.
Definition sds.hh:2191
virtual void List() const
List the contents of the structure to standard output.
Definition sds.hh:2099
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
virtual Id Copy() const
Factory constructor method Id Copy constructor.
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
static Id CreateArgStruct(const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure.
virtual std::string toString(int maxlen=200)
Convert the structure to a string.
Definition sds.hh:2918
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
DRAMA 2 main include file.
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:93
void SafePrintf(std::ostream &ostream, const char *str)
Safe formatted write to a stream.