static const char *rcsId="@(#) $Id: ACMM:Drama2/examples/argtest.cpp,v 1.45+ 22-Feb-2016 14:09:53+11 tjf $";
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);
fprintf(stderr,"Converted to string = \"%s\"\n",
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"));
}