Giter VIP home page Giter VIP logo

Comments (4)

mel-odious avatar mel-odious commented on May 9, 2024

Or it could be done by adding unrecognised options as std::string options with a flag that marks them as unrecognised (so Get(), Add() etc. can still behave like they don't really exist) which would simplify writing them all back to XML in alphabetical order.

from freeorion.

geoffthemedio avatar geoffthemedio commented on May 9, 2024

As suggested, Options set by SetFromXMLRecursive (and perhaps SetFromCommandLine) that don't find an existing already-Added option in the DB could add a string-valued Option to the map.

When Adding an option in code, it checks for an existing option by the same name already, and throws an exception if a duplicate is found.

Instead, it could set the value of the new Option to whatever is already set in the existing Option by taking the result of the existing Option's GetValueString() function, and attempting to lexical_cast that to whatever the newly-Added Option's type is.

No need for an extra flag, I think.

If the lexical_cast fails, then use the default value of the newly-Added Option.

from freeorion.

mel-odious avatar mel-odious commented on May 9, 2024

That approach wouldn't allow functions such as Get(), Validate() or OptionExists() to tell the difference between options that have been registered with Add() (and therefore have the proper type info, validators, descriptions, defaults etc.) and ones that were merely found in the config or command line with no context. I just threw up a PR with the "save as a string Option with a flag" approach over here if you'd like to inspect it. Haven't done anything with SetFromCommandLine there but it would make sense for that to behave similarly to SetFromXMLRecursive.

from freeorion.

geoffthemedio avatar geoffthemedio commented on May 9, 2024

Seems reasonable

from freeorion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.