From 2cecda2ec76aa235cdbc5e4af9bd3614a5b4e52f Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Thu, 10 Jan 2013 10:07:43 +0000 Subject: [PATCH] Limited testing of condition string parser, seems to work. Next step is tying in libloadorder to get the list of active plugins. --- docs/BOSS Metadata File Syntax.html | 25 +++++++++------------ src/parsers.h | 6 ++--- src/tester.cpp | 35 ++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/docs/BOSS Metadata File Syntax.html b/docs/BOSS Metadata File Syntax.html index abed0fa2..29905d9a 100644 --- a/docs/BOSS Metadata File Syntax.html +++ b/docs/BOSS Metadata File Syntax.html @@ -84,7 +84,6 @@ This documentation is a work in progress, covering a syntax that is also still a
  • Tag Data Structure
  • Plugin Data Structure -
  • Message Strings
  • Condition Strings
    1. Functions @@ -158,7 +157,7 @@ plugins: Key NameRequiredNotes type✓The type string can be one of three keywords, see the table below for their semantics. - content✓The actual message content string. It has a few special properties, see Message Strings for details. + content✓The actual message content string. URLs in message content strings will be turned into hyperlinks in BOSS's user interface. Recognised URLs are those that start with file:, http: or https:. URLs can be labelled by writing the label after the URL, with a space separating them, and enclosing the URL and label in double quotes. condition✗A condition string that is evaluated to determine whether the message should be displayed: if it evaluates to true, the message is displayed, otherwise it is not. See Condition Strings for details. lang✗What language this message is written in, given as an ISO 639-3 language code. The languages BOSS supports are given in Language Codes. If no language is given, then the message will always be displayed. If a language is given and it does not match the language BOSS is running for, the message will not be displayed, otherwise its display is dependent on the evaluation of the condition string, if present. @@ -172,11 +171,19 @@ plugins: errorAn error message, decribing a critical installation issue (eg. missing masters). -

      Example: +

      Examples: condition: 'file("Silgrad_Tower.esm")' type: warn content: Use either Silgrad_Tower.esm or Silgrad_Tower_T.esm but not both together. +A content string of +See http://www.example.com for more information. +would be displayed as +

      See http://www.example.com for more information.
      +while +See "http://www.example.com example link" for more information. +would be displayed as +
      See example link for more information.

      File Data Structure

      Not to be confused with the structure of the metadata file itself, this structure can be used to hold filenames. It has two forms: the first is a simple string, and the second is a key-value map. All values in the map are strings. @@ -249,18 +256,6 @@ msg: content: 'Do not clean. "Dirty" edits are intentional and required for the mod to function.' -

      Message Strings

      -

      URLs in message content strings will be turned into hyperlinks in BOSS's user interface. Recognised URLs are those that start with file:, http: or https: and contain no spaces (valid URLs can't contain spaces anyway). URLs can be labelled by writing the label after the URL, with a space separating them, and enclosing the URL and label in double quotes. -

      Examples: -http://www.example.com -becomes -

      http://www.example.com
      -while -"http://www.example.com example link" -becomes -
      example link
      - -

      Condition Strings

      Condition strings can be used to ensure that data is only acted on by BOSS under certain circumstances. They are very similar to boolean conditional expressions in programming languages such as Python, though more limited. Their EBNF grammar is: [ negator ], function, { junctor, [ negator ], function } ; diff --git a/src/parsers.h b/src/parsers.h index 4b1b1b76..45ff40df 100644 --- a/src/parsers.h +++ b/src/parsers.h @@ -2,7 +2,7 @@ A plugin load order optimiser for games that use the esp/esm plugin system. - Copyright (C) 2012 WrinklyNinja + Copyright (C) 2012-2013 WrinklyNinja This file is part of BOSS. @@ -341,10 +341,10 @@ namespace boss { comparator %= unicode::string("==") | unicode::string("!=") - | unicode::string("<") - | unicode::string(">") | unicode::string("<=") | unicode::string(">=") + | unicode::string("<") + | unicode::string(">") ; expression.name("expression"); diff --git a/src/tester.cpp b/src/tester.cpp index 651d11c2..ea233f6f 100644 --- a/src/tester.cpp +++ b/src/tester.cpp @@ -2,6 +2,8 @@ #include #include "metadata.h" #include "parsers.h" +#include "game.h" +#include "globals.h" #include #include @@ -23,7 +25,7 @@ int main() { cout << "Testing masterlist parser." << endl; - YAML::Node test = YAML::LoadFile("masterlist.yaml"); + YAML::Node test = YAML::LoadFile("masterlist-example.yaml"); list globalMessages; if (test["globals"]) { @@ -33,19 +35,19 @@ int main() { } } - set pluginData; + list pluginData; if (test["plugins"]) { YAML::Node plugins = test["plugins"]; for (YAML::const_iterator it=plugins.begin(); it != plugins.end(); ++it) { - pluginData.insert(it->as()); + pluginData.push_back(it->as()); } } cout << "Testing masterlist generator." << endl; - minimisePluginList(pluginData); + // minimisePluginList(pluginData); - ofstream out("minimal.yaml"); + ofstream out("generated.yaml"); YAML::Emitter yout; yout.SetIndent(2); yout << YAML::BeginMap @@ -56,5 +58,28 @@ int main() { out << yout.c_str(); out.close(); + cout << "Testing game settings structure." << endl; + + boss::Game game(BOSS_GAME_TES5, "/media/oliver/6CF05918F058EA3A/Program Files (x86)/Steam/steamapps/common/skyrim"); + + for (list::iterator it=pluginData.begin(), endIt=pluginData.end(); it != endIt; ++it) { + try { + it->EvalAllConditions(game); + } catch (std::runtime_error& e) { + cout << e.what() << endl; + } + } + + ofstream out2("evaled.yaml"); + YAML::Emitter yout2; + yout2.SetIndent(2); + yout2 << YAML::BeginMap + << YAML::Key << "globals" << YAML::Value << globalMessages + << YAML::Key << "plugins" << YAML::Value << pluginData + << YAML::EndMap; + + out2 << yout2.c_str(); + out2.close(); + return 0; }