Beispiel #1
0
/**
 * \brief Returns a field of this entity if it exists.
 * \param key Key of the field to get.
 * \return The corresponding field or a nil field.
 */
FieldValue EntityData::get_field(const std::string& key) const {

    const auto& it = fields.find(key);
    if (it == fields.end()) {
        return FieldValue();
    }

    return it->second;
}
bool Cx_CfgRecord::AddFieldValue(const std::wstring& wstrField, 
                                 const std::wstring& wstrValue)
{
    ASSERT(IsValid() && !wstrValue.empty());
    ASSERT_MESSAGE(DbFunc::IsDBName(wstrField.c_str()), "Invalid field name.");
    ASSERT_MESSAGE(!HasFieldValue(wstrField), "The field has already set value.");

    m_arrValue.push_back(FieldValue(wstrField, wstrValue));

    return true;
}
Beispiel #3
0
const char* GnSQLiteTable::GetStringField(const char* szField, const char* szNullValue/*=""*/)
{
	if ( FieldIsNull(szField) )
	{
		return szNullValue;
	}
	else
	{
		return FieldValue(szField);
	}
}
Beispiel #4
0
double GnSQLiteTable::GetFloatField(const char* szField, double fNullValue/*=0.0*/)
{
	if ( FieldIsNull(szField) )
	{
		return fNullValue;
	}
	else
	{
		return atof( FieldValue(szField) );
	}
}
Beispiel #5
0
double GnSQLiteTable::GetFloatField(int nField, double fNullValue/*=0.0*/)
{
	if ( FieldIsNull( nField ) )
	{
		return fNullValue;
	}
	else
	{
		return atof( FieldValue( nField ) );
	}
}
Beispiel #6
0
int GnSQLiteTable::GetIntField(const char* szField, int nNullValue/*=0*/)
{
	if ( FieldIsNull( szField ) )
	{
		return nNullValue;
	}
	else
	{
		return atoi( FieldValue( szField ) );
	}
}
Beispiel #7
0
int GnSQLiteTable::GetIntField(int nField, int nNullValue/*=0*/)
{
	if ( FieldIsNull( nField ) )
	{
		return nNullValue;
	}
	else
	{
		return atoi( FieldValue( nField ) );
	}
}
Beispiel #8
0
void Metadata::setFieldValue( const std::string& sFieldName, const vmf::Variant& value )
{
    // Check field against description
    if( m_spDesc == nullptr )
    {
        VMF_EXCEPTION(NullPointerException, "Metadata description object is missing!" );
    }

    FieldDesc fieldDesc;
    if( !m_spDesc->getFieldDesc( fieldDesc, sFieldName ) )
    {
        VMF_EXCEPTION(IncorrectParamException, "Metadata field not found in metadata description" );
    }

    iterator it = this->findField( sFieldName );

    // Check field type
    if( fieldDesc.type == value.getType() )
    {
        if( it != this->end() )
        {
            *it = vmf::FieldValue( sFieldName, value );
        }
        else
        {
            this->emplace_back(sFieldName, value);
        }
    }
    // If the field type is not the same, try to convert it to the right type
    else
    {
        vmf::Variant varNew( value );
        // This line may throw exception
        varNew.convertTo( fieldDesc.type );

        if( it != this->end() )
        {
            *it = vmf::FieldValue( sFieldName, varNew );
        }
        else
        {
            this->emplace_back( FieldValue( sFieldName, varNew ) );
        }
    }
}
Beispiel #9
0
void Metadata::addValue( const vmf::Variant& value )
{
    // Check field against description
    if( m_spDesc == nullptr )
    {
        VMF_EXCEPTION(NullPointerException, "Metadata description object is missing!" );
    }

    FieldDesc fieldDesc;
    if( !m_spDesc->getFieldDesc( fieldDesc ) )
    {
        VMF_EXCEPTION(InternalErrorException, "Metadata field not found in metadata description" );
    }

    // Check field type
    if( fieldDesc.type != value.getType() )
    {
        VMF_EXCEPTION(TypeCastException, "Field type does not match!" );
    }

    this->emplace_back( FieldValue( "", value ) );
}
Beispiel #10
0
const char* CppSQLite3Query::FieldValue(const char *szField)
{
	int nField = FieldIndex(szField);
	return FieldValue(nField);
}
Beispiel #11
0
bool GnSQLiteTable::FieldIsNull(const char* szField)
{
	CheckResults();
	return ( FieldValue(szField) == 0 );
}
Beispiel #12
0
bool GnSQLiteTable::FieldIsNull(int nField)
{
	CheckResults();
	return ( FieldValue(nField) == 0 );
}
MetricDimensionKey getMockMetricDimensionKey(int key, string value) {
    int pos[] = {key, 0, 0};
    HashableDimensionKey dim;
    dim.addValue(FieldValue(Field(1, pos, 0), Value(value)));
    return MetricDimensionKey(dim, DEFAULT_DIMENSION_KEY);
}