387{
389
390
391 switch (tid) {
392 default:
393 cm_msg(
MERROR,
"db_paste_json",
"do not know what to do with tid %d at \"%s\"", tid, path);
394
397 cm_msg(
MERROR,
"db_paste_json",
"paste of TID_ARRAY is not implemented at \"%s\"", path);
400 cm_msg(
MERROR,
"db_paste_json",
"paste of TID_STRUCT is not implemented at \"%s\"", path);
403 cm_msg(
MERROR,
"db_paste_json",
"paste of TID_BITFIELD is not implemented at \"%s\"", path);
406 const std::string
value = node->GetString();
407 int size = 1;
410 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_CHAR value for \"%s\", db_set_data_index() status %d", path,
status);
412 }
414 }
417 if (node->GetType() == MJSON_STRING && node->GetString() == "true") {
418 v = true;
419 } else if (node->GetType() == MJSON_STRING && node->GetString() == "false") {
420 v = false;
421 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'y') {
422 v = true;
423 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'n') {
424 v = false;
425 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'Y') {
426 v = true;
427 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'N') {
428 v = false;
429 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 't') {
430 v = true;
431 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'f') {
432 v = false;
433 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'T') {
434 v = true;
435 } else if (node->GetType() == MJSON_STRING && node->GetString()[0] == 'F') {
436 v = false;
437 } else {
444 }
445 int size = sizeof(v);
448 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_BOOL value for \"%s\", db_set_data_index() status %d", path,
status);
450 }
452 }
460 int size = sizeof(b);
463 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_BYTE/TID_SBYTE value for \"%s\", db_set_data_index() status %d", path,
status);
465 }
467 }
475 int size = sizeof(v);
478 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_WORD/TID_SHORT value for \"%s\", db_set_data_index() status %d", path,
status);
480 }
482 }
488 int size = sizeof(v);
491 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_DWORD value for \"%s\", db_set_data_index() status %d", path,
status);
493 }
495 }
497 int v = 0;
498 switch (node->GetType()) {
499 default:
500 cm_msg(
MERROR,
"db_paste_json",
"unexpected node type %d at \"%s\"", node->GetType(), path);
502 case MJSON_INT: {
503 v = node->GetInt();
504 break;
505 }
506 case MJSON_NUMBER: {
507 double dv = node->GetDouble();
508 if (dv > INT_MAX || dv < INT_MIN) {
509 cm_msg(
MERROR,
"db_paste_json",
"numeric value %f out of range at \"%s\"", dv, path);
511 }
512 v = (int)dv;
513 break;
514 }
515 case MJSON_STRING: {
519 break;
520 }
521 }
522 int size = sizeof(v);
525 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_INT value for \"%s\", db_set_data_index() status %d", path,
status);
527 }
529 }
530
536 int size = sizeof(v);
539 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_UINT64 value for \"%s\", db_set_data_index() status %d", path,
status);
541 }
543 }
544
550 int size = sizeof(v);
553 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_INT64 value for \"%s\", db_set_data_index() status %d", path,
status);
555 }
557 }
558
560 double dv;
564 float v = dv;
565 int size = sizeof(v);
568 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_FLOAT value for \"%s\", db_set_data_index() status %d", path,
status);
570 }
572 }
574 double v;
578 int size = sizeof(v);
581 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_DOUBLE value for \"%s\", db_set_data_index() status %d", path,
status);
583 }
585 }
587 char* buf = NULL;
588 const char* ptr = NULL;
589 int size = 0;
590 const std::string
value = node->GetString();
591 if (string_length == 0)
593
594 if (string_length) {
595 buf = new char[string_length];
596 mstrlcpy(buf,
value.c_str(), string_length);
597 ptr = buf;
598 size = string_length;
599 } else {
601 size = strlen(ptr) + 1;
602 }
603
604 if (is_array) {
608 cm_msg(
MERROR,
"db_paste_json",
"cannot get key of string array for \"%s\", db_get_key() status %d", path,
status);
610 }
611
615 cm_msg(
MERROR,
"db_paste_json",
"cannot change array string length from %d to %d for \"%s\", db_resize_string() status %d",
key.
item_size, size, path,
status);
617 }
618 }
619 }
620
621
622
623 if (string_length > 0) {
624 if (is_array) {
626 } else {
628 }
629 }
else if (
index != 0) {
630 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_STRING value for \"%s\" index %d, it is not an array", path,
index);
632 } else {
634 }
635
636 if (buf)
637 delete[] buf;
638
640 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_STRING value for \"%s\", db_set_data_index() status %d", path,
status);
642 }
643
645 }
647 std::string value_string = node->GetString();
648 const char*
value = value_string.c_str();
649 int size = strlen(
value) + 1;
650
652
654 cm_msg(
MERROR,
"db_paste_json",
"cannot set TID_LINK value for \"%s\", db_set_data() status %d", path,
status);
656 }
657
659 }
660 }
661
662}
INT db_set_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
INT EXPRT db_resize_string(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_length)
static int GetDOUBLE(const MJsonNode *node, const char *path, double *dw)
static int GetDWORD(const MJsonNode *node, const char *path, DWORD *dw)
static int GetQWORD(const MJsonNode *node, const char *path, UINT64 *qw)
unsigned long long UINT64