예제 #1
0
void Cask::CdapOdbc::DataReader::fetchValue(const web::json::value& value, const ColumnBinding& binding) {
  std::wstring strValue;
  SQLDOUBLE dblValue = NAN;
  switch (binding.getTargetType()) {
    case SQL_CHAR:
      strValue = to_wstring(value);
      this->fetchVarchar(strValue.c_str(), binding);
      break;
    case SQL_WCHAR:
      strValue = to_wstring(value);
      this->fetchWVarchar(strValue.c_str(), binding);
      break;
    case SQL_DOUBLE:
      if (value.is_string()) {
        dblValue = std::wcstod(value.as_string().c_str(), nullptr);
      } else if (value.is_integer()) {
        dblValue = value.as_integer();
      } else if (value.is_double()) {
        dblValue = value.as_double();
      } else if (value.is_number()) {
        dblValue = value.as_number().to_double();
      } else if (value.is_boolean()) {
        dblValue = value.as_bool() ? 1.0 : 0.0;
      }

      this->fetchDouble(dblValue, binding);
      break;
  }
}
예제 #2
0
void Error_error::fromJson(web::json::value& val)
{
    if(val.has_field(utility::conversions::to_string_t("message")))
    {
        setMessage(ModelBase::stringFromJson(val[utility::conversions::to_string_t("message")]));
    }
    if(val.has_field(utility::conversions::to_string_t("name")))
    {
        setName(ModelBase::stringFromJson(val[utility::conversions::to_string_t("name")]));
    }
}
예제 #3
0
//creates GDD object from jason values 
vector<vector<int>> GDD_generator(web::json::value jsonValue, network net)
{
	vector<vector<int>> igdd(net.Number_of_Vertices, vector<int>(73));
	for (int i = 0; i<jsonValue.size(); ++i)
	{
		igdd[i / 73][i % 73] = jsonValue.at(i).as_integer();
		i++;
	}

	return igdd;
}
예제 #4
0
void Tag::fromJson(web::json::value& val)
{
    if(val.has_field(U("id")))
    {
        setId(ModelBase::int64_tFromJson(val[U("id")]));
    }
    if(val.has_field(U("name")))
    {
        setName(ModelBase::stringFromJson(val[U("name")]));
    }
}
예제 #5
0
etcd::Value::Value(web::json::value const & json_value)
  : _key(json_value.has_field(JSON_KEY) ? json_value.at(JSON_KEY).as_string() : ""),
    dir(json_value.has_field(JSON_DIR)),
    value(json_value.has_field(JSON_VALUE) ? json_value.at(JSON_VALUE).as_string() : ""),
    created(json_value.has_field(JSON_CREATED) ? json_value.at(JSON_CREATED).as_number().to_int64() : 0),
    modified(json_value.has_field(JSON_MODIFIED) ? json_value.at(JSON_MODIFIED).as_number().to_int64() : 0)
{
}
예제 #6
0
void Object::fromJson(web::json::value& val)
{
    if (val.is_object())
    {
        m_object = val;
    }
}
예제 #7
0
void display_field_map_json(web::json::value  jvalue)
{
   if (!jvalue.is_null())
   {
      for (auto const & e : jvalue.as_object())
      {
         std::wcout 
         	/*<< typeid(e.first).name()*/ 
         	// << e.first/*.as_string()*/ 
         	<< L" : " 
         	/*<< typeid(e.second.as_string()).name()*/ 
         	// << e.second.as_string() 
         	<< std::endl;
      	// std::wcout << e.as_string() << std::endl;
      }
   }
}
예제 #8
0
void ApiResponse::fromJson(web::json::value& val)
{
    if(val.has_field(U("code")))
    {
        setCode(ModelBase::int32_tFromJson(val[U("code")]));
    }
    if(val.has_field(U("type")))
    {
        setType(ModelBase::stringFromJson(val[U("type")]));
                
    }
    if(val.has_field(U("message")))
    {
        setMessage(ModelBase::stringFromJson(val[U("message")]));
                
    }
    
}
예제 #9
0
void Order::fromJson(web::json::value& val)
{
    if(val.has_field(utility::conversions::to_string_t("id")))
    {
        setId(ModelBase::int64_tFromJson(val[utility::conversions::to_string_t("id")]));
    }
    if(val.has_field(utility::conversions::to_string_t("petId")))
    {
        setPetId(ModelBase::int64_tFromJson(val[utility::conversions::to_string_t("petId")]));
    }
    if(val.has_field(utility::conversions::to_string_t("quantity")))
    {
        setQuantity(ModelBase::int32_tFromJson(val[utility::conversions::to_string_t("quantity")]));
    }
    if(val.has_field(utility::conversions::to_string_t("shipDate")))
    {
        setShipDate(ModelBase::dateFromJson(val[utility::conversions::to_string_t("shipDate")]));
    }
    if(val.has_field(utility::conversions::to_string_t("status")))
    {
        setStatus(ModelBase::stringFromJson(val[utility::conversions::to_string_t("status")]));
    }
    if(val.has_field(utility::conversions::to_string_t("complete")))
    {
        setComplete(ModelBase::boolFromJson(val[utility::conversions::to_string_t("complete")]));
    }
}
예제 #10
0
파일: indiv.cpp 프로젝트: boubad/intrarest
	bool Indiv::setField(const FieldValue t, const web::json::value & value) {
		switch (t) {
		case FieldValue::hasimage:
			this->m_hasimage =
				((!value.is_null()) && value.is_boolean()) ?
				value.as_bool() : false;
			return true;
		case FieldValue::imagedata: {
										this->m_size = 0;
										this->m_data.reset();
										if (value.is_array()) {
											const size_t n = value.size();
											if (n > 0) {
												this->m_data.reset(new byte[n]);
												byte *pDest = this->m_data.get();
												if (pDest != nullptr) {
													for (size_t i = 0; i < n; ++i) {
														byte b = (byte) 0;
														auto v = value.get(i);
														if ((!v.is_null()) && v.is_number()) {
															b = (byte) v.as_integer();
														}
														pDest[i] = b;
													} // i
													this->m_size = n;
												} // pDest
											} // n
										} // array
		}
			return true;
		default:
			break;
		} // t
		return (DatasetChild::setField(t, value));
	} // setField
예제 #11
0
void Cask::CdapOdbc::ColumnMapper::map(const web::json::value& data) {
  assert(data.is_array());
  for (auto& item : this->columnBindings) {
    auto desc = this->getDesc(item);
    if (desc) {
      if (item.getTargetType() == SQL_C_CHAR) {
        auto value = data.at(desc->getPosition());
        std::wstring strValue;

        if (!value.is_null()) {
          strValue = value.as_string();
        }

        copyString(value.is_null() ? nullptr : &strValue, item.getTargetValuePtr(), item.getBufferLength(), item.getStrLenOrInd());
      }
    } else {
      // Column not found
      if (item.getTargetType() == SQL_C_CHAR) {
        copyString(nullptr, item.getTargetValuePtr(), item.getBufferLength(), item.getStrLenOrInd());
      }
    }
  }
}
예제 #12
0
void gltfWriter::TechniqueParameters (FbxNode *pNode, web::json::value &techniqueParameters, web::json::value &attributes, web::json::value &accessors) {
	for ( const auto &iter : attributes.as_object () ) {
		utility::string_t name =iter.first ;
		std::transform (name.begin (), name.end (), name.begin (), ::tolower) ;
		//std::replace (name.begin (), name.end (), U('_'), U('x')) ;
		name.erase (std::remove (name.begin (), name.end (), U('_')), name.end ()) ;
		utility::string_t upperName (iter.first) ;
		std::transform (upperName.begin (), upperName.end (), upperName.begin (), ::toupper) ;
		web::json::value accessor =accessors [iter.second.as_string ()] ;
		techniqueParameters [name] =web::json::value::object ({
			{ U("semantic"), web::json::value::string (upperName) },
			{ U("type"), web::json::value::number ((int)IOglTF::techniqueParameters (accessor [U("type")].as_string ().c_str (), accessor [U("componentType")].as_integer ())) }
		}) ;
	}
}
예제 #13
0
void JsonPrettify::formatValue (web::json::value &val, utility::ostream_t &stream) {
	if ( val.is_array () )
		formatArray (val.as_array (), stream) ;
	else if ( val.is_object () )
		formatObject (val.as_object (), stream) ;
	else if ( val.is_string () )
		format_string (val.as_string (), stream) ;
	else if ( val.is_boolean () )
		format_boolean (val.as_bool (), stream) ;
	else if ( val.is_integer () )
		format_integer (val.as_integer (), stream) ;
	else if ( val.is_double () )
		format_double (val.as_double (), stream) ;
	else if ( val.is_null () )
		format_null (stream) ;
}
예제 #14
0
web::json::value gltfWriter::WriteTechnique (FbxNode *pNode, FbxSurfaceMaterial *pMaterial, web::json::value &techniqueParameters) {
	web::json::value commonProfile =web::json::value::object () ;
	// The FBX SDK does not have such attribute. At best, it is an attribute of a Shader FX, CGFX or HLSL.
	commonProfile [U("extras")] =web::json::value::object ({{ U("doubleSided"), web::json::value::boolean (false) }}) ;
	commonProfile [U("lightingModel")] =web::json::value::string (LighthingModel (pMaterial)) ;
	commonProfile [U("parameters")] =web::json::value::array () ;
	if ( _uvSets.size () ) {
		commonProfile [U("texcoordBindings")] =web::json::value::object () ;
		for ( auto iter : _uvSets ) {
			utility::string_t key (iter.first) ;
			std::string::size_type i =key.find (U("Color")) ;
			if ( i != std::string::npos )
				key.erase (i, 5) ;
			std::transform (key.begin (), key.end (), key.begin (), ::tolower) ;
			commonProfile [U("texcoordBindings")] [key] =web::json::value::string (iter.second) ;
		}
	}
	for ( const auto &iter : techniqueParameters.as_object () ) {
		if (   (  utility::details::limitedCompareTo (iter.first, U("position")) != 0
			   && utility::details::limitedCompareTo (iter.first, U("normal")) != 0
			   && utility::details::limitedCompareTo (iter.first, U("texcoord")) != 0)
			|| iter.first == U("normalMatrix")
			)
			commonProfile [U("parameters")] [commonProfile [U("parameters")].size ()] =web::json::value::string (iter.first) ;

		web::json::value param =iter.second ;
		if ( param [U("type")].as_integer () == IOglTF::SAMPLER_2D ) {

		}
	}

	web::json::value details =web::json::value::object () ;
	details [U("commonProfile")] =commonProfile ;
	details [U("type")] =web::json::value::string (FBX_GLTF_COMMONPROFILE) ;

	web::json::value attributes =web::json::value::object () ;
	for ( const auto &iter : techniqueParameters.as_object () ) {
		if (   utility::details::limitedCompareTo (iter.first, U("position")) == 0
			|| (utility::details::limitedCompareTo (iter.first, U("normal")) == 0 && iter.first != U("normalMatrix"))
			|| utility::details::limitedCompareTo (iter.first, U("texcoord")) == 0 )
			attributes [utility::string_t (U("a_")) + iter.first] =web::json::value::string (iter.first) ;
	}

	web::json::value instanceProgram=web::json::value::object () ;
	instanceProgram [U("attributes")] =attributes ;
	instanceProgram [U("program")] =web::json::value::string (createUniqueId (utility::string_t (U("program")), 0)) ;
	instanceProgram [U("uniforms")] =web::json::value::object () ;
	for ( const auto &iter : techniqueParameters.as_object () ) {
		if (   (  utility::details::limitedCompareTo (iter.first, U("position")) != 0
			   && utility::details::limitedCompareTo (iter.first, U("normal")) != 0
			   && utility::details::limitedCompareTo (iter.first, U("texcoord")) != 0)
			|| iter.first == U("normalMatrix") )
			instanceProgram [U("uniforms")] [utility::string_t (U("u_")) + iter.first] =web::json::value::string (iter.first) ;
	}

	web::json::value techStatesEnable =web::json::value::array () ;
	if ( pNode->mCullingType != FbxNode::ECullingType::eCullingOff )
		techStatesEnable [techStatesEnable.size ()] =web::json::value::number ((int)IOglTF::CULL_FACE) ;
	// TODO: should it always be this way?
	techStatesEnable [techStatesEnable.size ()] =web::json::value::number ((int)IOglTF::DEPTH_TEST) ;

	web::json::value techStates =web::json::value::object () ;
	techStates [U("enable")] =techStatesEnable ;
	// TODO: needs to be implemented
	//techStates [U("functions")] =

	web::json::value techniquePass =web::json::value::object () ;
	techniquePass [U("details")] =details ;
	techniquePass [U("instanceProgram")] =instanceProgram ;
	techniquePass [U("states")] =techStates ;

	web::json::value technique =web::json::value::object () ;
	technique [U("parameters")] =techniqueParameters ;
	technique [U("pass")] =web::json::value::string (U("defaultPass")) ;
	technique [U("passes")] =web::json::value::object ({{ U("defaultPass"), techniquePass }}) ;

	return (technique) ;
}