コード例 #1
0
Configuration::Configuration(std::string path)
: ConfigurationReader(path) {

	hostSpeed = GetDoubleValue("Host.speed", 2900.0);

	processorLevel = GetProcessorTypeValue("CPU.level");
	speed = GetDoubleValue("CPU.speed", 2.0);
	pollIntervalMilliseconds = GetIntValue("CPU.pollIntervalMilliseconds", 10);

	inputAddress = GetUShortValue("IO.inputAddress");
	outputAddress = GetUShortValue("IO.outputAddress");

	romPath = GetStringValue("ROM.path");
	romLoadAddress = GetUShortValue("ROM.loadAddress");

	ramPath = GetStringValue("RAM.path");
	ramLoadAddress = GetUShortValue("RAM.loadAddress");

	bbcLanguageRomPath = GetStringValue("BBC.language.path");
	bbcOSRomPath = GetStringValue("BBC.OS.path");
	bbcVduEmulation = GetBooleanValue("BBC.VDUEmulation");

	startAddress = GetUShortValue("run.startAddress");
	resetStart = GetBooleanValue("run.resetStart");
	stopBreak = GetBooleanValue("run.stopBreak");
	breakInstruction = GetByteValue("run.breakInstruction", 0x00);
	stopWhenLoopDetected = GetBooleanValue("run.stopWhenLoopDetected");
	stopAddress = GetUShortValue("run.stopAddress");
	stopAddressEnabled = stopAddress != 0;

#ifdef _DEBUG
	disassemble = GetBooleanValue("debug.disassemble");
	disassemblyLogPath = GetStringValue("debug.disassemblyLogPath");
	debugFile = GetStringValue("debug.debugFile");
	countInstructions = GetBooleanValue("debug.countInstructions");
	profileAddresses = GetBooleanValue("debug.profileAddresses");
#else
	disassemble = GetBooleanValue("release.disassemble");
	disassemblyLogPath = GetStringValue("release.disassemblyLogPath");
	debugFile = GetStringValue("release.debugFile");
	countInstructions = GetBooleanValue("release.countInstructions");
	profileAddresses = GetBooleanValue("release.profileAddresses");
#endif
}
コード例 #2
0
ATTR_METHOD_IMPL(CElementParser, OnNillable)
{
    TRACE_PARSE_ENTRY();

    CElement * pCurr = GetElement();
    if (pCurr != NULL)
    {
        bool bVal;
        HRESULT hr = GetBooleanValue(&bVal, wszValue, cchValue);
        if (SUCCEEDED(hr))
        {
            pCurr->SetNullable(bVal);
            return S_OK;
        }

        EmitInvalidValue("nillable", wszValue);
    }

    EmitErrorHr(E_OUTOFMEMORY);
    return E_FAIL;
}
コード例 #3
0
static AwaOpaque MakeOpaqueValue(const char * value, int length)
{
    return (AwaOpaque) { .Data = (void *)value, length };
}

static int AddTargetWithValue(const AwaServerSession * session, AwaServerWriteOperation * operation, const Target * target, const char * value)
{
    int result = 0;

    if (operation != NULL)
    {
        if (target != NULL)
        {
            if (value != NULL)
            {
                if (Server_IsResourceDefined(session, target->Path))
                {
                    AwaResourceType resourceType = Server_GetResourceType(session, target->Path);
                    if (resourceType != AwaResourceType_Invalid )
                    {
                        if (IsIDValid(target->ResourceInstanceID))
                        {
                            Verbose("Set %s %s/%d <- %s\n", ResourceTypeToString(resourceType), target->Path, target->ResourceInstanceID, value);
                            if (!IsArrayType(resourceType))
                            {
                                Error("Error: resource %s is not an array; do not specify a resource instance ID\n", target->Path);
                                result = -1;
                            }
                        }
                        else
                        {
                            Verbose("Set %s %s <- %s\n", ResourceTypeToString(resourceType), target->Path, value);
                            if (IsArrayType(resourceType))
                            {
                                Error("Error: resource is an array; specify a resource instance ID: %s/x\n", target->Path);
                                result = -1;
                            }
                        }

                        if (result == 0)
                        {
                            switch (resourceType)
                            {
                                case AwaResourceType_None:
                                {
                                    Error("Resource %s is of type None and cannot be set\n", target->Path);
                                    result = -1;
                                    break;
                                }

                                case AwaResourceType_String:
                                {
                                    if (AwaServerWriteOperation_AddValueAsCString(operation, target->Path, value) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsCString failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_Integer:
                                {
                                    AwaInteger tmp = strtoimax(value, NULL, 10);
                                    if (AwaServerWriteOperation_AddValueAsInteger(operation, target->Path, tmp) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsInteger failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_Float:
                                {
                                    AwaFloat tmp = 0.0;
                                    sscanf(value, "%20lf", &tmp);
                                    if (AwaServerWriteOperation_AddValueAsFloat(operation, target->Path, tmp) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsFloat failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_Boolean:
                                {
                                    AwaBoolean boolValue = GetBooleanValue(value);
                                    if (AwaServerWriteOperation_AddValueAsBoolean(operation, target->Path, boolValue) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsBoolean failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_Opaque:
                                {
                                    AwaOpaque opaqueValue = MakeOpaqueValue(value, strlen(value));
                                    if (AwaServerWriteOperation_AddValueAsOpaque(operation, target->Path, opaqueValue) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsOpaque failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_Time:
                                {
                                    AwaTime tmp = strtoimax(value, NULL, 10);
                                    if (AwaServerWriteOperation_AddValueAsTime(operation, target->Path, tmp) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsTime failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_ObjectLink:
                                {
                                    AwaObjectLink objectLink;
                                    if (!SetObjectLinkFromInput(&objectLink, value))
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsObjectLink failed\n");
                                        result = -1;
                                        break;
                                    }

                                    if (AwaServerWriteOperation_AddValueAsObjectLink(operation, target->Path, objectLink) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddValueAsObjectLink failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_IntegerArray:
                                {
                                    AwaInteger tmp = strtoimax(value, NULL, 10);
                                    if (AwaServerWriteOperation_AddArrayValueAsInteger(operation, target->Path, target->ResourceInstanceID, tmp) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsInteger failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_StringArray:
                                {
                                    if (AwaServerWriteOperation_AddArrayValueAsCString(operation, target->Path, target->ResourceInstanceID, value) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsCString failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_FloatArray:
                                {
                                    AwaFloat tmp = 0.0;
                                    sscanf(value, "%20lf", &tmp);
                                    if (AwaServerWriteOperation_AddArrayValueAsFloat(operation, target->Path, target->ResourceInstanceID, tmp) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsFloat failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_BooleanArray:
                                {
                                    AwaBoolean boolValue = GetBooleanValue(value);
                                    if (AwaServerWriteOperation_AddArrayValueAsBoolean(operation, target->Path, target->ResourceInstanceID, boolValue) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsBoolean failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_OpaqueArray:
                                {
                                    AwaOpaque opaqueValue = MakeOpaqueValue(value, strlen(value));
                                    if (AwaServerWriteOperation_AddArrayValueAsOpaque(operation, target->Path, target->ResourceInstanceID, opaqueValue) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsOpaque failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_TimeArray:
                                {
                                    AwaTime tmp = strtoimax(value, NULL, 10);
                                    if (AwaServerWriteOperation_AddArrayValueAsTime(operation, target->Path, target->ResourceInstanceID, tmp) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsTime failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                case AwaResourceType_ObjectLinkArray:
                                {
                                    AwaObjectLink objectLink;
                                    if (!SetObjectLinkFromInput(&objectLink, value))
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsObjectLink failed\n");
                                        result = -1;
                                        break;
                                    }

                                    if (AwaServerWriteOperation_AddArrayValueAsObjectLink(operation, target->Path, target->ResourceInstanceID, objectLink) != AwaError_Success)
                                    {
                                        Error("AwaServerWriteOperation_AddArrayValueAsObjectLink failed\n");
                                        result = -1;
                                    }
                                    break;
                                }

                                default:
                                    Error("Unhandled type\n");
                                    result = -1;
                            }
                        }
                    }
                }
                else
                {
                    Error("%s is not defined\n", target->Path);
                    result = -1;
                }
            }
            else
            {
                Error("value is NULL\n");
                result = -1;
            }
        }
        else
        {
            Error("target is NULL\n");
            result = -1;
        }
    }
    else
    {
        Error("operation is NULL\n");
        result = -1;
    }
    return result;
}
コード例 #4
0
bool ConfigurationReader::GetBooleanValue(std::string path, bool defaultValue) {
	return GetBooleanValue(m_root, path, defaultValue);
}
コード例 #5
0
bool ConfigurationReader::GetBooleanValue(const boost::property_tree::ptree& root, std::string path) {
	return GetBooleanValue(root, path, false);
}
コード例 #6
0
bool ConfigurationReader::GetBooleanValue(std::string path) {
	return GetBooleanValue(path, false);
}
コード例 #7
0
ファイル: configfile.cpp プロジェクト: pmprog/ROTMenu
bool ConfigFile::GetBooleanValue( std::string Key, bool* Value )
{
	return GetBooleanValue( Key, 0, Value );
}