void print::operator()(object_t const &m) const { using namespace std; if(mode_) { if(depth_) (*os_) << "\n"; PRINT_SPACE(depth_, *os_); } (*os_) << "{"; if(mode_) (*os_) << "\n"; object_t::const_iterator i = m.begin(); object_t::const_iterator j = m.begin(); ++depth_; while(i != m.end()){ if(mode_) PRINT_SPACE(depth_, *os_); (*this)(i->first); (*os_) << " : "; boost::apply_visitor(*this, i->second); if(++i != m.end()) { (*os_) << ","; if(mode_) (*os_) << "\n"; } } depth_--; if(mode_) { (*os_) << "\n"; PRINT_SPACE(depth_, *os_); } (*os_) << "}"; if(mode_ && !depth_) (*os_) << "\n"; }
S32 LLSDJSONParser::parseObject( object_t obj, LLSD& data ) const { S32 object_count = 0; iterator_t iter = obj.begin(); const iterator_t end = obj.end(); // for( ; iter != end; ++iter ) { std::string name = iter->first; variant_t var = iter->second; // if( var->type() == typeid(std::string) ) { data[name] = boost::any_cast<std::string>(*var); object_count++; } else if( var->type() == typeid(bool) ) { data[name] = boost::any_cast<bool>(*var); object_count++; } else if( var->type() == typeid(int) ) { data[name] = boost::any_cast<int>(*var); object_count++; } else if( var->type() == typeid(double) ) { data[name] = boost::any_cast<double>(*var); object_count++; } else if( var->type() == typeid(object_t) ) { object_count += parseObject( boost::any_cast<object_t>(*var), data[name] ); } else { data[name] = "null"; object_count++; } } return object_count; }
static void extract(const object_t &json, char* json_ptr, const char *key, const std::size_t &len, T &value) { jsonpack::key k; k._bytes = len; k._ptr = key; object_t::const_iterator found = json.find(k); if( found != json.end() ) // exist the current key { if( match_token_type(found->second) ) { extract(found->second, json_ptr, value); } else { std::string msg = derived::invalid_value_msg(); throw type_error( msg.data() ); } } }
static void extract(const object_t &json, char* json_ptr, const char *key, const std::size_t &len, Seq &value) { jsonpack::key k; k._bytes = len; k._ptr = key; object_t::const_iterator found = json.find(k); if( found != json.end() ) // exist the current key { if(found->second._field == _ARR ) { extract(found->second, json_ptr, value); } else { std::string msg = "Invalid array value for key: "; msg += key; throw type_error( msg.data() ); } } }
w_rc_t get_key_info( const rid_t& W_IFDEBUG3(W_IFTRACE(rid)), // record id const object_t& obj_in, key_cookie_t cookie, // type info factory_t& , skey_t* key ) { int k = cookie.make_int(); DBG(<<"get_key_info for key " << k); metadata* meta = (metadata *)obj_in.hdr(0); // we shouldn't be called if this is the case w_assert1(meta[k].nullable || !meta[k].fixed); DBG(<<"get_key_info for keys " << k << " offset=" << meta[k].offset << " length=" << meta[k].length ); new(key) skey_t(obj_in, meta[k].offset, meta[k].length, false); #if W_DEBUG_LEVEL > 2 if(1) { #undef DBG #define DBG(x) cout x << endl; DBG( << "KEY " << k << " METADATA ARE: " << " offset=" << meta[k].offset << " length=" << meta[k].length ); DBG( << rid << " body (" << (obj_in.body_size() - meta[k].offset) << " bytes worth) = " ); char *object = (char *)obj_in.body(meta[k].offset); if(meta[k].length > 0) { switch(meta[k].t) { case test_bv: case test_blarge: case test_b23: case test_b1: { int l = meta[k].length; char *p = object; if(l > 1) { if(strlen(p) > 256) { while (*p == 'E') p++; } if(p-object > 0) { DBG(<<" E(" <<(int)(p-object) <<" times)" << p); } else { while(*p) { w_assert3(*p <= upper_alpha && *p >= lower_alpha); p++; } DBG( << object); } } else { // print as character w_assert3(*p <= upper_alpha && *p >= lower_alpha); DBG( << *object); } }
void generic_diode::save(pstring name, object_t &parent) { parent.save(m_Vd, name + ".m_Vd"); parent.save(m_Id, name + ".m_Id"); parent.save(m_G, name + ".m_G"); }
immediate_then_t move_to(object_t<Stream, context_t<Value>, Time>& x, Value to) { x.set_context(to); return immediate_then_t(); }