Changeset 19805 for trunk/FACT++/src


Ignore:
Timestamp:
10/27/19 12:52:15 (5 years ago)
Author:
tbretz
Message:
Added a 'Map' which is a resource of the kind 'something/somethingelse'
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Configuration.cc

    r19454 r19805  
    15581558        << std::endl;
    15591559}
     1560
     1561// --------------------------------------------------------------------------
     1562//
     1563//! Splits a given argument of the form something/somethingelse into its
     1564//! two parts something and somethingelse and stores it in the pair of
     1565//! Configuration::Map.
     1566//!
     1567std::istream &operator>>(std::istream &in, Configuration::Map &m)
     1568{
     1569    const istreambuf_iterator<char> eos;
     1570    string txt(istreambuf_iterator<char>(in), eos);
     1571
     1572    const boost::regex expr("((.*)[^\\\\])/(.*)");
     1573    boost::smatch match;
     1574    if (!boost::regex_match(txt, match, expr))
     1575        throw runtime_error("Could not evaluate map argument: "+txt);
     1576
     1577    m.first  = match[1].str();
     1578    m.second = match[3].str();
     1579
     1580    return in;
     1581}
  • trunk/FACT++/src/Configuration.h

    r19385 r19805  
    8080
    8181public:
     82    struct Map : std::pair<std::string, std::string>
     83    {
     84        Map() { }
     85    };
     86
    8287    Configuration(const std::string &prgname="");
    8388    virtual ~Configuration() { }
     
    281286{ return po::value<bool>()->implicit_value(true)->default_value(def); }
    282287
     288
     289std::istream &operator>>(std::istream &in, Configuration::Map &m);
     290
    283291#endif
Note: See TracChangeset for help on using the changeset viewer.