Ejemplo n.º 1
0
 std::string SafeGetField_String(lua_State* L, int index, int key)
 {
   if (HasField(L, index, key))
     return GetField_String(L, index, key);
   assert(false);
   return std::string();
 }
Ejemplo n.º 2
0
 double SafeGetField_Number(lua_State* L, int index, int key)
 {
   if (HasField(L, index, key))
     return GetField_Number(L, index, key);
   assert(false);
   return double();
 }
Ejemplo n.º 3
0
 int SafeGetField_Integer(lua_State* L, int index, const std::string& key)
 {
   if (HasField(L, index, key))
     return GetField_Integer(L, index, key);
   assert(false);
   return int();
 }
Ejemplo n.º 4
0
 bool SafeGetField_Boolean( lua_State* L, int index, const std::string& key )
 {
   if (HasField(L, index, key))
     return GetField_Boolean(L, index, key);
   assert(false);
   return false;
 }
Ejemplo n.º 5
0
AString _DataProxy::operator[](const std::string& field) const {
    if (HasField(field)) {
        return const_access(const_access(data->values, category), field);
    }
    else {
        return AString("");
    }
}
Ejemplo n.º 6
0
void UVaRestJsonObject::MergeJsonObject(UVaRestJsonObject* InJsonObject, bool Overwrite)
{
	TArray<FString> Keys = InJsonObject->GetFieldNames();
	
	for (auto Key : Keys)
	{
		if (Overwrite == false && HasField(Key))
		{
			continue;
		}
		
		SetField(Key, InJsonObject->GetField(Key));
	}
}
Ejemplo n.º 7
0
TfEnum
SdfAttributeSpec::GetDisplayUnit() const
{
    // The difference between this and the macro version is that the
    // macro calls _GetValueWithDefault().  That checks if the value
    // is empty and, if so, returns the default value from the schema.
    // But we want to return a default displayUnit that's based on
    // the role.
    TfEnum displayUnit;
    if (HasField(SdfFieldKeys->DisplayUnit, &displayUnit)) {
        return displayUnit;
    }

    return GetTypeName().GetDefaultUnit();
}
Ejemplo n.º 8
0
void Pb2Json::Message2Json(const ProtobufMsg& message, Json& json, bool enum2str) {
    auto descriptor = message.GetDescriptor();
    auto reflection = message.GetReflection();
    if (nullptr == descriptor || nullptr == descriptor) return;

    auto count = descriptor->field_count();

    for (auto i = 0; i < count; ++i) {
        const auto field = descriptor->field(i);

        if (field->is_repeated()) {
            if (reflection->FieldSize(message, field) > 0)
                RepeatedMessage2Json(message, field, reflection, json[field->name()], enum2str);

            continue;
        }

        if (!reflection->HasField(message, field)) {
            continue;
        }

        switch (field->type()) {
            case ProtobufFieldDescriptor::TYPE_MESSAGE: {
                const ProtobufMsg& tmp_message = reflection->GetMessage(message, field);
                if (0 != tmp_message.ByteSize()) Message2Json(tmp_message, json[field->name()]);
            } break;

            case ProtobufFieldDescriptor::TYPE_BOOL:
                json[field->name()] = reflection->GetBool(message, field) ? true : false;
                break;

            case ProtobufFieldDescriptor::TYPE_ENUM: {
                auto* enum_value_desc = reflection->GetEnum(message, field);
                if (enum2str) {
                    json[field->name()] = enum_value_desc->name();
                } else {
                    json[field->name()] = enum_value_desc->number();
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_INT32:
            case ProtobufFieldDescriptor::TYPE_SINT32:
            case ProtobufFieldDescriptor::TYPE_SFIXED32:
                json[field->name()] = reflection->GetInt32(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_UINT32:
            case ProtobufFieldDescriptor::TYPE_FIXED32:
                json[field->name()] = reflection->GetUInt32(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_INT64:
            case ProtobufFieldDescriptor::TYPE_SINT64:
            case ProtobufFieldDescriptor::TYPE_SFIXED64:
                json[field->name()] = reflection->GetInt64(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_UINT64:
            case ProtobufFieldDescriptor::TYPE_FIXED64:
                json[field->name()] = reflection->GetUInt64(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_FLOAT:
                json[field->name()] = reflection->GetFloat(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_STRING:
            case ProtobufFieldDescriptor::TYPE_BYTES:
                json[field->name()] = reflection->GetString(message, field);
                break;

            default:
                break;
        }
    }
}
Ejemplo n.º 9
0
 bool HasField( lua_State* L, const std::string& key )
 {
   return HasField(L, -1, key);
 }
Ejemplo n.º 10
0
 bool HasField( lua_State* L, int key )
 {
   return HasField(L, -1, key);
 }
Ejemplo n.º 11
0
const mat &AnalysisResults::GetFieldElement(const QString &key, const uword &index)
{
    if (!HasField(key) || (HasField(key) && index >= fields_[key]->n_elem))
        return empty_matrix_;
    else return fields_[key]->at(index);
}