Exemplo n.º 1
0
void CMetadata::_vecJsonToBson(rapidjson::Value& json, mongo::BSONArrayBuilder& vecBuilder)
{
	for(int i=0; i<this->_getVecCount(json); ++i) {

		rapidjson::Value& member = this->getFieldVec(json, i);

		if (this->isFieldI64(member)) {
			vecBuilder.append(this->getFieldI64(member));
		}
		else if (this->isFieldInt(member)) {
			vecBuilder.append(this->getFieldInt(member));
		}
		else if (this->isFieldStr(member)) {
			vecBuilder.append(this->getFieldStr(member));
		}
		else if (this->isFieldObj(member)) {
			mongo::BSONObjBuilder objbuilder;
			for (rapidjson::Value::MemberIterator it = member.MemberBegin(); it != member.MemberEnd(); ++it) {
				this->_fieldJsonToBson(member, it->name.GetString(), objbuilder);
			}
			vecBuilder.append(objbuilder.obj());
		}
	}
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
bool joint_c::insert( mongo::BSONArrayBuilder& bson_array, Reveal::Core::joint_ptr joint ) {
  mongo::BSONObjBuilder bob;
  bob.append( FIELD_ID, joint->id );

  mongo::BSONArrayBuilder bab_q;
  for( unsigned i = 0; i < joint->state.size_q(); i++ )
    bab_q.append( joint->state.q(i) );
  bob.appendArray( FIELD_STATE_POSITION, bab_q.arr() );
  
  mongo::BSONArrayBuilder bab_dq;
  for( unsigned i = 0; i < joint->state.size_dq(); i++ ) 
    bab_dq.append( joint->state.dq(i) );
  bob.appendArray( FIELD_STATE_VELOCITY, bab_dq.arr() );

  mongo::BSONArrayBuilder bab_u;
  for( unsigned i = 0; i < joint->control.size_u(); i++ ) 
    bab_u.append( joint->control.u(i) ); 
  bob.appendArray( FIELD_CONTROL, bab_u.arr() );

  bson_array.append( bob.obj() );

  return true;
}