void s_print_value(PullParser& data_parser){ const bnj_val& v = data_parser.GetValue(); unsigned type = bnj_val_type(&v); switch(type){ case BNJ_NUMERIC: /* If nonzero exponent, then float. */ if(v.exp_val){ double d; BNJ::Get(d, data_parser); printf("%lf", d); } else{ if(v.type & BNJ_VFLAG_NEGATIVE_SIGNIFICAND){ int d; BNJ::Get(d, data_parser); printf("%i", d); } else{ unsigned d; BNJ::Get(d, data_parser); printf("%u", d); } } break; case BNJ_STRING: /* TODO loop to get entire string value..for now just output fixed chars. */ { char buffer[1024]; data_parser.ChunkRead8(buffer, 1024); printf("%s", buffer); } break; case BNJ_SPECIAL: { static const char* special[BNJ_COUNT_SPC] = { "false", "true", "null", "NaN", "Infinity" }; unsigned idx = bnj_val_special(&v); if(BNJ_SPC_INFINITY == idx && (v.type & BNJ_VFLAG_NEGATIVE_SIGNIFICAND)){ printf("-Infinity"); } else{ printf("%s", special[idx]); } } break; default: throw PullParser::invalid_value("Expecting simple value!", data_parser); } }