37 << file <<
" contains OKS time data stored in deprecated format \'" << data
38 <<
"\'. Please refresh it using an oks application. Support for such format will be removed in a future release.",
39 ((
const char*)file)((
const char*)data))
53 data.
TIME = *
reinterpret_cast<uint64_t*
>(&t);
59 return boost::gregorian::date(boost::gregorian::gregorian_calendar::from_day_number(data.DATE));
62boost::posix_time::ptime
65 return *
reinterpret_cast<boost::posix_time::ptime*
>(
const_cast<uint64_t*
>(&data.TIME));
71 for (OksData::List::const_iterator i = dlist.begin(); i != dlist.end(); ++i) {
83 size_t l1Lenght = l1.size();
84 size_t l2Lenght = l2.size();
86 if (!l1Lenght && !l2Lenght)
88 if (l1Lenght != l2Lenght)
96 for (; i1 != l1.end(); ++i1, ++i2) {
106 ((!d1->data.OBJECT && !d2->data.OBJECT) ||
107 ((d1->data.OBJECT && d2->data.OBJECT) &&
108 (d1->data.OBJECT->GetClass()->get_name() == d2->data.OBJECT->GetClass()->get_name()) &&
109 (d1->data.OBJECT->GetId() == d2->data.OBJECT->GetId())))) ||
124 return ((d.type ==
type) &&
140 ((
type ==
uid_type) && (d.data.UID.class_id->get_name() ==
data.
UID.class_id->get_name() &&
141 *d.data.UID.object_id == *
data.
UID.object_id)) ||
143 (*d.data.UID2.class_id == *
data.
UID2.class_id && *d.data.UID2.object_id == *
data.
UID2.object_id)) ||
151 return ((d == *
this) ?
false :
true);
157 const char* fname =
"OksData::operator[<|<=|>|>=](const OksData&) const";
158 const char* h3 =
"Can't compare ";
188 return data.
UID.class_id->get_name();
193#define CMP_OBJ(OP, c1, c2, id1, id2) (c1 OP c2) || (!(c2 OP c1) && id1 OP id2)
195#define CMP_DATA(OP) \
198 return (*data.STRING OP * d.data.STRING); \
200 return (data.U32_INT OP d.data.U32_INT); \
202 return (data.S32_INT OP d.data.S32_INT); \
204 return (data.U16_INT OP d.data.U16_INT); \
206 return (data.S16_INT OP d.data.S16_INT); \
208 return (data.S8_INT OP d.data.S8_INT); \
210 return (data.U8_INT OP d.data.U8_INT); \
212 return (data.S64_INT OP d.data.S64_INT); \
214 return (data.U64_INT OP d.data.U64_INT); \
216 return (data.FLOAT OP d.data.FLOAT); \
218 return (data.DOUBLE OP d.data.DOUBLE); \
220 return (data.BOOL OP d.data.BOOL); \
222 return (data.DATE OP d.data.DATE); \
224 return (data.TIME OP d.data.TIME); \
226 return (*data.ENUMERATION OP * d.data.ENUMERATION); \
228 return (data.CLASS->get_name() OP d.data.CLASS->get_name()); \
232 return CMP_OBJ(OP, __cn(), d.__cn(), __oid(), d.__oid()); \
264 if (test_comparable(
type, d.type) ==
false)
272 if (test_comparable(
type, d.type) ==
false)
280 if (test_comparable(
type, d.type) ==
false)
288 if (test_comparable(
type, d.type) ==
false)
301 for (List::iterator i = d.data.LIST->begin(); i != d.data.LIST->end(); ++i) {
336 data.
UID.class_id = d.data.UID.class_id;
354 for (OksData::List::iterator i = d.data.LIST->begin(); i != d.data.LIST->end(); ++i) {
356 if ((*i) != d.data.LIST->back())
364 s <<
'\"' << *(d.data.STRING) <<
'\"';
369 s <<
'[' << d.data.OBJECT->GetId() <<
'@' << d.data.OBJECT->GetClass()->get_name() <<
']';
376 s <<
'#' <<
'[' << *d.data.UID2.object_id <<
'@' << *d.data.UID2.class_id <<
']';
380 s <<
'#' <<
'[' << *d.data.UID.object_id <<
'@' << d.data.UID.class_id->get_name() <<
']';
400 std::streamsize p = s.precision();
401 s.precision(std::numeric_limits<float>::digits10);
408 std::streamsize p = s.precision();
409 s.precision(std::numeric_limits<double>::digits10);
416 s << static_cast<int16_t>(d.data.S8_INT);
420 s << static_cast<uint16_t>(d.data.U8_INT);
432 s << ((d.data.BOOL ==
true) ?
"true" :
"false");
436 s << boost::gregorian::to_simple_string(d.date());
440 s << boost::posix_time::to_simple_string(d.time());
444 s <<
'\"' << *(d.data.ENUMERATION) <<
'\"';
448 s <<
'[' << d.data.CLASS->get_name() <<
']';
452 Oks::error_msg(
"operator<<(ostream&, const OksData&)") <<
"Can't put to stream \'OksData::unknown_type\'";
466 if (!dlist->empty()) {
506 std::ostringstream s;
511 s <<
'\'' << *d <<
'\'';
512 s <<
" is out of range \'" <<
range <<
'\'';
519 std::ostringstream s;
522 s <<
"string \'" << value <<
'\'';
527 s <<
" is not a valid value for \'" <<
type <<
"\' type";
530 s <<
":\n" << reason;
538 std::ostringstream s;
540 s <<
"the string is not a valid value for \'" <<
type <<
"\' type";
543 s <<
":\n" << reason;
551 if (a->p_range_obj ==
nullptr)
561 if (a->p_range_obj->validate(*
this) ==
false) {
614 SetFast(boost::gregorian::day_clock::universal_day());
617 SetFast(boost::posix_time::second_clock::universal_time());
633 data.
S8_INT =
static_cast<int8_t
>(strtol(s, 0, 0));
636 data.
U8_INT =
static_cast<uint8_t
>(strtoul(s, 0, 0));
644 data.
BOOL = (*s ==
't' || *s ==
'T' || *s ==
'1');
651 data.
U32_INT =
static_cast<uint32_t
>(strtoul(s, 0, 0));
654 data.
S32_INT =
static_cast<int32_t
>(strtol(s, 0, 0));
657 data.
S16_INT =
static_cast<int16_t
>(strtol(s, 0, 0));
660 data.
U16_INT =
static_cast<uint16_t
>(strtoul(s, 0, 0));
663 data.
S64_INT =
static_cast<int64_t
>(strtoll(s, 0, 0));
666 data.
U64_INT =
static_cast<uint64_t
>(strtoull(s, 0, 0));
682 }
catch (std::exception& ex) {
687 if (strchr(s,
'-') || strchr(s,
'/')) {
688 SetFast(boost::gregorian::from_simple_string(s));
691 SetFast(boost::gregorian::from_undelimited_string(s));
694 }
catch (std::exception& ex) {
699 if (strlen(s) == 15 && s[8] ==
'T') {
700 SetFast(boost::posix_time::from_iso_string(s));
703 SetFast(boost::posix_time::time_from_string(s));
706 }
catch (std::exception& ex) {
710 if (OksClass* c = a->p_class->get_kernel()->find_class(s)) {
724std::list<std::string>
727 std::list<std::string> val;
734 for (OksData::List::const_iterator i = d.data.LIST->begin(); i != d.data.LIST->end(); ++i) {
735 val.push_back((*i)->str());
745 if (!a->get_is_multi_values()) {
765 while (
str.length()) {
766 while (
str.length() &&
str[0] ==
' ')
770 char delimeter = (
str[0] ==
'\"' ?
'\"' :
str[0] ==
'\'' ?
'\'' :
str[0] ==
'`' ?
'`' :
',');
772 if (delimeter !=
',')
774 std::string::size_type p =
str.find(delimeter);
777 d->type = a->get_data_type();
782 std::string token(
str, 0, p);
783 d->data.ENUMERATION = a->get_enum_value(token);
785 std::string token(
str, 0, p);
786 d->SetValue(token.c_str(), a);
793 if (delimeter !=
',') {
795 if (p == std::string::npos)
826 throw std::runtime_error(
"empty numeric value");
838 }
else if (c ==
' ' || c ==
'\n' || c ==
'\r' || c ==
'\t') {
846 }
catch (std::exception& ex) {
853OksData::read(
const ReadFileParams& read_params,
const OksAttribute* a, int32_t num)
867OksData::read(
const ReadFileParams& read_params,
const OksAttribute* a)
869 const char* read_value =
"";
871 OksXmlInputStream& fxs(read_params.s);
874 switch (a->get_data_type()) {
876 read_value =
"quoted string";
878 size_t len = fxs.get_quoted();
880 data.
STRING->assign(fxs.get_xml_token().m_buf, len);
890 read_value =
"signed 32 bits integer";
891 fxs.get_num_token(
'<');
892 Set(
static_cast<int32_t
>(strtol(fxs.m_cvt_char->m_buf, &__sanity, 0)));
893 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
898 read_value =
"unsigned 32 bits integer";
899 fxs.get_num_token(
'<');
900 Set(
static_cast<uint32_t
>(strtoul(fxs.m_cvt_char->m_buf, &__sanity, 0)));
901 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
906 read_value =
"signed 16 bits integer";
907 fxs.get_num_token(
'<');
908 Set(
static_cast<int16_t
>(strtol(fxs.m_cvt_char->m_buf, &__sanity, 0)));
909 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
914 read_value =
"unsigned 16 bits integer";
915 fxs.get_num_token(
'<');
916 Set(
static_cast<uint16_t
>(strtoul(fxs.m_cvt_char->m_buf, &__sanity, 0)));
917 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
922 read_value =
"signed 8 bits integer";
923 fxs.get_num_token(
'<');
924 Set(
static_cast<int8_t
>(strtol(fxs.m_cvt_char->m_buf, &__sanity, 0)));
925 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
930 read_value =
"unsigned 8 bits integer";
931 fxs.get_num_token(
'<');
932 Set(
static_cast<uint8_t
>(strtoul(fxs.m_cvt_char->m_buf, &__sanity, 0)));
933 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
938 read_value =
"signed 64 bits integer";
939 fxs.get_num_token(
'<');
940 Set(
static_cast<int64_t
>(strtoll(fxs.m_cvt_char->m_buf, &__sanity, 0)));
941 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
946 read_value =
"unsigned 64 bits integer";
947 fxs.get_num_token(
'<');
948 Set(
static_cast<uint64_t
>(strtoull(fxs.m_cvt_char->m_buf, &__sanity, 0)));
949 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
954 read_value =
"float";
955 fxs.get_num_token(
'<');
956 Set(strtof(fxs.m_cvt_char->m_buf, &__sanity));
957 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
962 read_value =
"double";
963 fxs.get_num_token(
'<');
964 Set(strtod(fxs.m_cvt_char->m_buf, &__sanity));
965 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
970 read_value =
"boolean";
971 fxs.get_num_token(
'<');
972 Set(
static_cast<bool>(strtol(fxs.m_cvt_char->m_buf, &__sanity, 0)));
973 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
978 read_value =
"quoted date string";
980 size_t len = fxs.get_quoted();
986 read_value =
"quoted time string";
988 size_t len = fxs.get_quoted();
994 read_value =
"quoted enum string";
996 size_t len = fxs.get_quoted();
997 SetE(fxs.get_xml_token().m_buf, len, a);
1002 read_value =
"two quoted class-name / object-id strings";
1005 size_t len = fxs.get_quoted();
1006 data.
UID2.class_id->assign(fxs.get_xml_token().m_buf, len);
1007 len = fxs.get_quoted();
1008 data.
UID2.object_id->assign(fxs.get_xml_token().m_buf, len);
1013 read_value =
"quoted class-type string";
1016 SetValue(fxs.get_xml_token().m_buf, a);
1022 std::ostringstream s;
1023 s <<
"Unknown attribute type \"" << (int)a->get_data_type() <<
"\" (line " << fxs.get_line_no() <<
", char "
1024 << fxs.get_line_pos() <<
')';
1025 throw std::runtime_error(s.str().c_str());
1028 }
catch (exception& e) {
1030 }
catch (std::exception& e) {
1036OksData::read(
const OksAttribute* a,
const OksXmlValue& value)
1038 const char* read_value =
"";
1042 switch (a->get_data_type()) {
1045 data.
STRING->assign(value.buf(), value.len());
1054 read_value =
"signed 32 bits integer";
1055 Set(
static_cast<int32_t
>(strtol(value.buf(), &__sanity, 0)));
1056 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1061 read_value =
"unsigned 32 bits integer";
1062 Set(
static_cast<uint32_t
>(strtoul(value.buf(), &__sanity, 0)));
1063 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1068 read_value =
"signed 16 bits integer";
1069 Set(
static_cast<int16_t
>(strtol(value.buf(), &__sanity, 0)));
1070 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1075 read_value =
"unsigned 16 bits integer";
1076 Set(
static_cast<uint16_t
>(strtoul(value.buf(), &__sanity, 0)));
1077 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1082 read_value =
"signed 8 bits integer";
1083 Set(
static_cast<int8_t
>(strtol(value.buf(), &__sanity, 0)));
1084 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1089 read_value =
"unsigned 8 bits integer";
1090 Set(
static_cast<uint8_t
>(strtoul(value.buf(), &__sanity, 0)));
1091 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1096 read_value =
"signed 64 bits integer";
1097 Set(
static_cast<int64_t
>(strtoll(value.buf(), &__sanity, 0)));
1098 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1103 read_value =
"unsigned 64 bits integer";
1104 Set(
static_cast<uint64_t
>(strtoull(value.buf(), &__sanity, 0)));
1105 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1110 read_value =
"float";
1111 Set(strtof(value.buf(), &__sanity));
1112 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1117 read_value =
"double";
1118 Set(strtod(value.buf(), &__sanity));
1119 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1124 read_value =
"boolean";
1125 Set(
static_cast<bool>(strtol(value.buf(), &__sanity, 0)));
1126 if (__builtin_expect((*__sanity != 0 || errno == ERANGE), 0))
1131 read_value =
"quoted date string";
1136 read_value =
"quoted time string";
1141 read_value =
"quoted enum string";
1142 SetE(value.buf(), value.len(), a);
1146 read_value =
"two quoted class-name / object-id strings";
1148 std::ostringstream s;
1149 s <<
"Unexpected uid2 type at (line " << value.line_no() <<
", char " << value.line_pos() <<
')';
1150 throw std::runtime_error(s.str().c_str());
1155 read_value =
"quoted class-type string";
1163 std::ostringstream s;
1164 s <<
"Unknown attribute type \"" << (int)a->get_data_type() <<
"\" (line " << value.line_no() <<
", char "
1165 << value.line_pos() <<
')';
1166 throw std::runtime_error(s.str().c_str());
1169 }
catch (exception& e) {
1171 }
catch (std::exception& e) {
1177OksData::read(
const OksAttribute* a,
const ReadFileParams& read_params)
1186 const char* tag_start = read_params.s.get_tag_start();
1194 OksXmlAttribute attr(read_params.s);
1197 OksXmlValue value(read_params.s.get_value(attr.p_value_len));
1200 std::ostringstream s;
1202 <<
"\" (line " << read_params.s.get_line_no() <<
", char " << read_params.s.get_line_pos() <<
')';
1203 throw std::runtime_error(s.str().c_str());
1207 OksXmlAttribute attr(read_params.s);
1209 if (
cmp_str1(attr.name(),
"/") ==
false) {
1210 std::ostringstream s;
1211 s <<
"Unexpected tag \"" << attr.name() <<
"\" instead of close tag (line " << read_params.s.get_line_no()
1212 <<
", char " << read_params.s.get_line_pos() <<
')';
1213 throw std::runtime_error(s.str().c_str());
1217 std::ostringstream s;
1218 s <<
"Unexpected tag \"" << tag_start <<
"\" (line " << read_params.s.get_line_no() <<
", char "
1219 << read_params.s.get_line_pos() <<
')';
1220 throw std::runtime_error(s.str().c_str());
1222 }
catch (exception& e) {
1224 }
catch (std::exception& e) {
1230OksData::read(
const ReadFileParams& read_params,
const OksRelationship* r, int32_t num)
1234 }
else if (__builtin_expect((!
data.
LIST->empty()), 0)) {
1242 if (__builtin_expect((d->type ==
OksData::uid2_type && d->data.UID2.class_id->empty()), 0))
1251OksData::read(
const ReadFileParams& read_params,
const OksRelationship* r)
1253 const OksClass* rel_class(r->p_class_type);
1254 OksString* class_id(0);
1255 const OksClass* c(0);
1256 OksXmlInputStream& fxs(read_params.s);
1262 size_t len = fxs.get_quoted();
1264 if (__builtin_expect((len > 0), 1)) {
1265 if (__builtin_expect((!read_params.alias_table), 1)) {
1266 if (__builtin_expect((rel_class != 0), 1)) {
1267 c = rel_class->get_kernel()->find_class(fxs.get_xml_token().m_buf);
1270 if (__builtin_expect((c == 0), 0)) {
1271 class_id =
new OksString(fxs.get_xml_token().m_buf, len);
1274 const char* class_name_str(fxs.get_xml_token().m_buf);
1276 if (class_name_str[0] ==
'@') {
1280 c = (rel_class ? rel_class->get_kernel()->find_class(class_name_str) : 0);
1283 read_params.alias_table->add_value(0, c);
1285 read_params.alias_table->add_value(
new OksString(class_name_str, len), 0);
1289 if (
const OksAliasTable::Value* value = read_params.alias_table->get(class_name_str)) {
1290 c = (value->class_ptr ? value->class_ptr : rel_class->get_kernel()->find_class(*value->class_name));
1292 Oks::warning_msg(
"OksData::read(const ReadFileParams&, const OksRelationship*")
1293 <<
" Can't find alias for class \'" << class_name_str
1295 " Possibly data file has been saved in old format\n";
1297 c = rel_class->get_kernel()->find_class(class_name_str);
1303 class_id =
new OksString(class_name_str, len);
1310 len = fxs.get_quoted();
1312 if (__builtin_expect((c == 0), 0)) {
1314 Set(class_id,
new OksString(fxs.get_xml_token().m_buf, len));
1323 std::string& obj_id((
const_cast<ReadFileParams&
>(read_params)).tmp);
1324 obj_id.assign(fxs.get_xml_token().m_buf, len);
1334 read_params.owner->OksObject::check_class_type(r, c);
1336 obj->add_RCR(read_params.owner, r);
1337 }
catch (exception& ex) {
1341 }
catch (std::exception& ex) {
1344 throw FailedRead(
"relationship value", ex.what());
1353OksData::read(
const OksRelationship* r,
const OksXmlRelValue& value)
1356 if (__builtin_expect((value.m_class ==
nullptr), 0)) {
1357 if (value.m_class_id) {
1358 Set(value.m_class_id,
new OksString(value.m_value.buf(), value.m_value.len()));
1359 value.m_class_id =
nullptr;
1367 OksObject*
obj = value.m_class->get_object(value.m_value.buf());
1370 Set(value.m_class,
new OksString(value.m_value.buf(), value.m_value.len()));
1376 value.m_file_params.owner->OksObject::check_class_type(r, value.m_class);
1378 obj->add_RCR(value.m_file_params.owner, r);
1379 }
catch (exception& ex) {
1380 if (value.m_class_id)
1381 delete value.m_class_id;
1383 }
catch (std::exception& ex) {
1384 if (value.m_class_id)
1385 delete value.m_class_id;
1386 throw FailedRead(
"relationship value", ex.what());
1395OksData::read(
const OksRelationship* r,
const ReadFileParams& read_params)
1404 const char* tag_start = read_params.s.get_tag_start();
1411 OksXmlRelValue value(read_params);
1415 OksXmlAttribute attr(read_params.s);
1426 value.m_class = read_params.owner->uid.class_id->get_kernel()->find_class(attr.value());
1427 if (__builtin_expect((value.m_class ==
nullptr && attr.value_len() > 0), 0)) {
1428 value.m_class_id =
new OksString(attr.value(), attr.value_len());
1431 value.m_value = read_params.s.get_value(attr.p_value_len);
1433 read_params.s.throw_unexpected_attribute(attr.name());
1436 if (value.is_empty() ==
false) {
1440 if (__builtin_expect((d->type ==
OksData::uid2_type && d->data.UID2.class_id->empty()), 0))
1446 }
catch (exception& e) {
1447 throw FailedRead(
"multi-value relationship", e);
1448 }
catch (std::exception& e) {
1449 throw FailedRead(
"multi-value relationship", e.what());
1452 std::ostringstream s;
1453 s <<
"Unexpected tag \"" << tag_start <<
"\" (line " << read_params.s.get_line_no() <<
", char "
1454 << read_params.s.get_line_pos() <<
')';
1455 throw std::runtime_error(s.str().c_str());
1457 }
catch (exception& e) {
1459 }
catch (std::exception& e) {
1476 xmls.put_value((
unsigned long)
data.
LIST->size());
1485 (*i)->WriteTo(xmls, put_number);
1521 std::ostream& s = xmls.get_stream();
1522 std::streamsize p = s.precision();
1523 s.precision(std::numeric_limits<float>::digits10);
1530 std::ostream& s = xmls.get_stream();
1531 std::streamsize p = s.precision();
1532 s.precision(std::numeric_limits<double>::digits10);
1539 xmls.put_value(
static_cast<int16_t
>(
data.
S8_INT));
1543 xmls.put_value(
static_cast<uint16_t
>(
data.
U8_INT));
1555 xmls.put_value((
short)(
data.
BOOL));
1559 xmls.put_quoted(boost::gregorian::to_iso_string(
date()).c_str());
1563 xmls.put_quoted(boost::posix_time::to_iso_string(
time()).c_str());
1579 <<
"Can't write \'" << (
type ==
unknown_type ?
"unknown" :
"relationship") <<
"_type\'\n";
1609 std::ostream& s = xmls.get_stream();
1610 std::streamsize p = s.precision();
1611 s.precision(std::numeric_limits<float>::digits10);
1618 std::ostream& s = xmls.get_stream();
1619 std::streamsize p = s.precision();
1620 s.precision(std::numeric_limits<double>::digits10);
1627 xmls.put_value(
static_cast<int16_t
>(
data.
S8_INT));
1631 xmls.put_value(
static_cast<uint16_t
>(
data.
U8_INT));
1643 xmls.put_value((
short)(
data.
BOOL));
1647 xmls.put(boost::gregorian::to_iso_string(
date()).c_str());
1651 xmls.put(boost::posix_time::to_iso_string(
time()).c_str());
1663 throw std::runtime_error(
"internal error: call OksData::WriteTo() on list");
1670 <<
"Can't write \'" << (
type ==
unknown_type ?
"unknown" :
"relationship") <<
"_type\'\n";
1682 OksAliasTable* alias_table,
1684 bool put_number)
const
1686 const char* fname =
"WriteTo(OksXmlOutputStream&, ...)";
1688 static std::string emptyName(
"");
1690 const std::string* class_name = 0;
1691 const std::string* object_id = 0;
1699 class_name = object_id = &emptyName;
1706 xmls.put_value((
unsigned long)
data.
LIST->size());
1716 (*i)->WriteTo(xmls, k, alias_table,
false, put_number);
1737 class_name = &
data.
UID.class_id->get_name();
1738 object_id =
data.
UID.object_id;
1746 if (!class_name->empty()) {
1751 xmls.put_quoted(class_name->c_str());
1757 const OksAliasTable::Value* value = alias_table->get(
static_cast<const OksString*
>(class_name));
1761 xmls.put_quoted(value->class_name->c_str());
1765 alias_table->add_key(
static_cast<OksString*
>(
const_cast<std::string*
>(class_name)));
1767 std::string s(*class_name);
1769 xmls.put_quoted(s.c_str());
1774 xmls.put_quoted(
"");
1778 xmls.put_quoted(object_id->c_str());
1797 to->data.LIST->push_back(item);
1806 item->Set(dd->data.OBJECT);
1808 item->Set(dd->data.UID.class_id, *dd->data.UID.object_id);
1810 item->Set(*dd->data.UID2.class_id, *dd->data.UID2.object_id);
1812 to->data.LIST->push_back(item);
1822 to->Set(from->data.OBJECT);
1824 to->Set(from->data.UID.class_id, *from->data.UID.object_id);
1826 to->Set(*from->data.UID2.class_id, *from->data.UID2.object_id);
1833 if (a->get_is_multi_values()) {
1839 std::string cvts =
str();
1840 item->ReadFrom(cvts.c_str(), a->get_data_type(), a);
1842 to->data.LIST->push_back(item);
1850 std::string cvts = dd->str();
1851 item->ReadFrom(cvts.c_str(), a->get_data_type(), a);
1853 to->data.LIST->push_back(item);
1863 to->ReadFrom(cvts.c_str(), a->get_data_type(), a);
1868list2str(
const OksData::List* l,
const OksKernel* k,
int base)
1870 std::ostringstream s;
1875 bool is_first =
true;
1877 for (OksData::List::const_iterator i = l->begin(); i != l->end(); ++i) {
1878 std::string s2 = (k ? (*i)->str(k) : (*i)->str(base));
1881 if (is_first ==
false) {
1902 return list2str(
data.
LIST, kernel, 0);
1905 std::ostringstream s;
1913 s <<
"#[" << *
data.
UID.object_id <<
'@' <<
data.
UID.class_id->get_name() <<
']';
1923 std::cerr <<
"ERROR [OksData::str(const OksKernel *)]: wrong use for such data: " << *
this << std::endl;
1940 return (
data.
BOOL ?
"true" :
"false");
1942 return list2str(
data.
LIST, 0, base);
1944 return boost::gregorian::to_simple_string(
date());
1946 return boost::posix_time::to_simple_string(
time());
1951 std::ostringstream s;
1954 s.setf((base == 10 ? std::ios::dec : base == 16 ? std::ios::hex : std::ios::oct), std::ios::basefield);
1955 s.setf(std::ios::showbase);
1992 s.precision(std::numeric_limits<float>::digits10);
1997 s.precision(std::numeric_limits<double>::digits10);
2002 std::cerr <<
"ERROR [OksData::str(int)]: wrong use for such data: " << *
this << std::endl;
2017 if (o->GetClass()->get_kernel()->get_silence_mode() !=
true) {
2018 std::cerr << msg <<
": value of \"" << r->get_name() <<
"\" relationship in object " << o
2019 <<
" must be non-null\n";
2023 if (o->GetClass()->get_kernel()->get_silence_mode() !=
true) {
2024 std::cerr << msg <<
": \"" << r->get_name() <<
"\" relationship in object " << o
2025 <<
" must contain at least one object\n";
2046boost::posix_time::ptime
2047str2time(
const char* value,
size_t len,
const char* file_name)
2049 if (len == 15 && value[8] ==
'T') {
2051 return boost::posix_time::from_iso_string(value);
2052 }
catch (std::exception& ex) {
2059 std::ostringstream text;
2060 text << std::setfill(
'0') << std::setw(4) << t.year() << std::setw(2) << (t.month() + 1) << std::setw(2)
2061 << t.day() <<
'T' << std::setw(2) << t.hour() << std::setw(2) << t.min() << std::setw(2) << t.sec();
2062 TLOG_DEBUG(1) <<
"parse OKS time: " << t <<
" => " << text.str();
2067 Oks::warning_msg(
"oks str2time") <<
"The file is using deprecated OKS time format \"" << value
2068 <<
"\"\nPlease refresh it using an oks application\nSupport for such format "
2069 "will be removed in a future release.\n";
2071 return boost::posix_time::from_iso_string(text.str());
2072 }
catch (exception& ex) {
2075 }
catch (std::exception& ex) {
2082boost::gregorian::date
2083str2date(
const char* value,
size_t len)
2085 if (len == 8 && value[2] !=
'/' && value[3] !=
'/') {
2087 return boost::gregorian::from_undelimited_string(value);
2088 }
catch (std::exception& ex) {
2094 std::ostringstream text;
2095 text << std::setfill(
'0') << std::setw(4) << t.year() << std::setw(2) << (t.month() + 1) << std::setw(2)
2097 TLOG_DEBUG(1) <<
"parse OKS date: " << t <<
" => " << text.str();
2099 Oks::warning_msg(
"oks str2date") <<
"The file is using deprecated OKS date format \"" << value
2100 <<
"\"\nPlease refresh it using an oks application.\nSupport for such format "
2101 "will be removed in a future release.\n";
2103 return boost::gregorian::from_undelimited_string(text.str());
2104 }
catch (exception& ex) {
2106 }
catch (std::exception& ex) {