Example #1
0
const LLBC_String &LLBC_Variant::AsStr() const
{
    if (IsRaw())
    {
        LLBC_Variant *nonConstThis = const_cast<LLBC_Variant *>(this);
        if (IsBool())
        {
            nonConstThis->_holder.str = 
                (_holder.raw.uint64Val ? "true" : "false");
        }
        else if (IsFloat() || IsDouble())
        {
            return nonConstThis->_holder.str =
                LLBC_Num2Str(_holder.raw.doubleVal);
        }
        else if (IsSignedRaw())
        {
            nonConstThis->_holder.str = LLBC_Num2Str(_holder.raw.int64Val);
        }
        else
        {
            nonConstThis->_holder.str = LLBC_Num2Str(_holder.raw.uint64Val);
        }
    }
    else if (!IsStr())
    {
        LLBC_Variant *nonConstThis = const_cast<LLBC_Variant *>(this);
        nonConstThis->CleanStrData();
    }

    return _holder.str;
}
bool CSettings::GetBool(String strSetting)
{
	if(IsBool(strSetting))
		return GetSetting(strSetting)->bValue;

	return false;
}
Example #3
0
LLBC_Variant &LLBC_Variant::BecomeBool()
{
    if (!IsBool())
    {
        *this = LLBC_Variant(AsBool());
    }

    return *this;
}
Example #4
0
bool AnnotationValue::GetValueAsBool() const
{
	if (!IsBool())
	{
		std::stringstream ss;
		ss << "Attempted to access " << GetTypeString() 
			<< " annotation as a bool.";
		throw AnnotationValueTypeException(ss.str());
	}
	return boost::get<bool>(value);
}
Example #5
0
inline bool Object::Get<bool>(const std::string &key) const
{
	auto value = Find(key);

	if(value->IsBool())
		return value->AsBool();
	else if(value->IsNumber())
		return value->AsNumber();
	else
		return std::stod(value->AsString());
}
bool CSettings::SetBool(String strSetting, bool bValue)
{
	if(IsBool(strSetting))
	{
		GetSetting(strSetting)->bValue = bValue;

		// Save the XML file
		Save();
		return true;
	}

	return false;
}
Example #7
0
bool OTVariable::SetValue(const bool bValue)
{
	if (!IsBool())
	{
		OTLog::vError("OTVariable::SetValue(bool): Error: This variable (%s) is not a bool.\n",
					  m_strName.Get());
		return false;
	}

	m_bValue = m_bValueBackup = bValue;

	return true;
}
bool CSettings::SetEx(String strSetting, String strValue)
{
	if(IsBool(strSetting))
		SetBool(strSetting, strValue.ToBoolean());
	else if(IsInteger(strSetting))
		SetInteger(strSetting, strValue.ToInteger());
	else if(IsFloat(strSetting))
		SetFloat(strSetting, strValue.ToFloat());
	else if(IsString(strSetting))
		SetString(strSetting, strValue);
	else if(IsList(strSetting))
		AddToList(strSetting, strValue);
	else
		return false;

	return true;
}
Example #9
0
static void SendMessage(TCircularQueue<std::pair<FName, TArray<FOscDataElemStruct>>> & _pendingMessages, const osc::ReceivedMessage & message)
{
    const FName address(message.AddressPattern());

    TArray<FOscDataElemStruct> data;
    
    const auto argBegin = message.ArgumentsBegin();
    const auto argEnd = message.ArgumentsEnd();
    for(auto it = argBegin; it != argEnd; ++it)
    {
        FOscDataElemStruct elem;
        if(it->IsFloat())
        {
            elem.SetFloat(it->AsFloatUnchecked());
        }
        else if(it->IsDouble())
        {
            elem.SetFloat(it->AsDoubleUnchecked());
        }
        else if(it->IsInt32())
        {
            elem.SetInt(it->AsInt32Unchecked());
        }
        else if(it->IsInt64())
        {
            elem.SetInt(it->AsInt64Unchecked());
        }
        else if(it->IsBool())
        {
            elem.SetBool(it->AsBoolUnchecked());
        }
        else if(it->IsString())
        {
            elem.SetString(FName(it->AsStringUnchecked()));
        }
        data.Add(elem);
    }

    // save it in pending messages
    _pendingMessages.Enqueue(std::make_pair(address, data));
}
bool CScValue::IsValBool()
{
    return IsBool();
}
Example #11
0
// InnerParse is poorly named; it really just accepts any character not handled in the calling function
// and determines the token type for unknown right-hand tokens.
void InnerParse( const char c, char& StrMark, Array< char >& TokenString, const int LineCount, SToken::ETokenType& InOutTokenType, bool* OutClosedString = NULL )
{
	switch( InOutTokenType )
	{
	case SToken::ET_None:
		// Determine the type of the RHS from the first character
		// (Can change from int to float later, on finding a . or f)
		if( IsNum( c ) || c == '-' )
		{
			InOutTokenType = SToken::ET_Int;
			TokenString.PushBack( c );
		}
		else if( IsBool( c ) )
		{
			InOutTokenType = SToken::ET_Bool;
			TokenString.PushBack( c );
		}
		else if( c == '\"' || c == '\'' )
		{
			InOutTokenType = SToken::ET_String;
			StrMark = c;
		}
		else if( c == '.' )
		{
			InOutTokenType = SToken::ET_Float;
			TokenString.PushBack( c );
		}
		else
		{
			PRINTF( "Unexpected character %c in undetermined token at line %d\n", c, LineCount );
			WARNDESC( "Unexpected character in undetermined token" );
		}
		break;
	case SToken::ET_Name:
	case SToken::ET_Context:
	case SToken::ET_Macro:
		TokenString.PushBack( c );
		break;
	case SToken::ET_Bool:
		TokenString.PushBack( c );
		break;
	case SToken::ET_Int:
		if( c == '.' )
		{
			InOutTokenType = SToken::ET_Float;
		}
		else
		{
			ASSERT( IsNum( c ) );
		}
		TokenString.PushBack( c );
		break;
	case SToken::ET_Float:
		ASSERT( IsNum( c ) || c == 'f' );
		TokenString.PushBack( c );
		break;
	case SToken::ET_String:
		if( c == StrMark )
		{
			TokenString.PushBack( '\0' );
			if( OutClosedString )
			{
				*OutClosedString = true;
			}
		}
		else
		{
			TokenString.PushBack( c );
		}
		break;
	default:
		WARNDESC( "Unexpected token" );
		break;
	}
}