コード例 #1
0
ファイル: ObjectType.cpp プロジェクト: azriel91/im.azriel
const ObjectType* ObjectType::loadFromFile(const string path, const int objectTypeId) {
	xml_document doc;
	const xml_parse_result result = doc.load_file(path.c_str());
#ifdef ENABLE_LOGGING
	LOGGER->info("Loaded [%s]. Result: [%s]", path.c_str(), result.description());
#endif

	xml_node node = doc.root().child("object");

	const xml_node headerNode = node.child("header");
	const Header* header = deserializeHeader(headerNode);

	auto const sequences = new vector<const Sequence*>(1);
	auto sequenceNodes = node.children("sequence");
	for (const xml_node sequenceNode : sequenceNodes) {
		auto const sequence = deserializeSequence(sequenceNode);
		const int sequenceId = sequence->getId();
		auto size = sequences->size();

		// ensure sufficient capacity
		if (size <= (unsigned int) sequenceId) {
			const double val = log2((double) sequenceId);
			const int newSize = 2 << (int) (ceil(val));
			sequences->resize(newSize);
		}
		sequences->at(sequenceId) = sequence;
	}

	return new ObjectType(objectTypeId, header, sequences);
}
コード例 #2
0
/// @brief Sets the license key to use for idoc.dll
/// @details The idoc_create function will not work unless the license key has been set and is
///     valid. If the license key is invalid, an error message will be written to the Replay log.
/// @param a string containing a license in XML format
/// @example
///     idoc_set_license(
///         "<license>"
///         "    <name>Joe User</name>"
///         "    <company>BigCo</company>"
///         "    <email>[email protected]</email>"
///         "    <key>ANUAA-ADHHB-BS7VU-MVH45-9ZG3B-U3PUQ</key>"
///         "    <expires>2013-10-01</expires>"
///         "</license>");
/// @todo Add the license key functionality using the SoftActivate API. Note: I will do this last,
///     as it is non-essential functionality.
IDOCREPLAYDLL_API BOOL idoc_set_license(const LPCSTR licenseXml)
{
    g_licenseValid = false;

    if (licenseXml == NULL)
    {
        lr_error_message("[%s] License key cannot be NULL.", __FUNCTION__);
        return g_licenseValid;
    }

    if (is_trace_log_enabled())
    {
        lr_output_message("[%s] Checking license key:\n%s", __FUNCTION__, licenseXml);
    }

    using namespace pugi;

    xml_document doc;
    const xml_parse_result parseResult = doc.load(licenseXml);
    if (!parseResult)
    {
        lr_error_message("[%s] Invalid license XML (%s).", __FUNCTION__, parseResult.description());
        return g_licenseValid;
    }

    const xml_node& root = doc.child("license");
    const std::string name(get_license_property_value(root, "name"));
    const std::string company(get_license_property_value(root, "company"));
    const std::string email(get_license_property_value(root, "email"));
    const std::string key(get_license_property_value(root, "key"));
    const std::string expires(get_license_property_value(root, "expires"));

    // TODO: check that the license is valid. If it is valid, set license_valid to true;

    g_licenseValid = true;

    // TODO: add trace messages for "expired license" and "invalid license" (i.e. they have tampered with the fields)
    if (g_licenseValid && is_trace_log_enabled())
    {
        lr_output_message("License key is valid. Expiry date: %TODO");
    }

    // The license key functionality has been implemented using the SoftActivate SDK. Example code for C++ can be
    // found at http://www.softactivate.com/

    // Before checking the license key, you will have to define the license key template.
    // The template used for checking must match the template that was used to generate the key. This template can be
    // found in the the Keygen VS Project.

    return g_licenseValid;
}
コード例 #3
0
/// @brief Select the input file from the Repository
/// @param the file name (including path) of the IDoc to use as input for any IDoc parameters
/// @return true if the file exists and was selected successfully
IDOCREPLAYDLL_API BOOL idoc_select_input_file(const LPCSTR filePath)
{
    g_idocParamInputFilePath.erase();
    g_idocParamInputFile.reset();

    if (!ensure_valid_license())
    {
        return FALSE;
    }

    if (filePath == NULL)
    {
        lr_error_message("[%s] File path cannot be NULL.", __FUNCTION__);
        return FALSE;
    }

    if (!Utils::FileExists(filePath))
    {
        lr_error_message("[%s] File \"%s\" is not found.", __FUNCTION__, filePath);
        return FALSE;
    }

    using namespace pugi;

    const xml_parse_result parseResult = g_idocParamInputFile.load_file(filePath);
    if (!parseResult)
    {
        lr_error_message("[%s] Invalid input file XML (%s).", __FUNCTION__, parseResult.description());
        return FALSE;
    }

    g_idocParamInputFilePath = filePath;
	if (is_trace_log_enabled())
    {
        lr_output_message("Selected IDoc input file: %s", filePath);
    }
    return TRUE;
}