| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /**
- * params.hh for jsonstroller
- *
- * Author: isundil <isundill@gmail.com>
- **/
- #pragma once
- #include <list>
- #include <string>
- #include <istream>
- class AParams
- {
- public:
- /**
- * true if --ascii
- **/
- virtual bool isIgnoringUnicode() const =0;
- /**
- * false if -W
- **/
- virtual bool isStrict() const =0;
- /**
- * true if --color match conditions
- **/
- virtual bool colorEnabled() const =0;
- };
- class Params: public AParams
- {
- public:
- Params(int ac, char **av);
- virtual ~Params();
- /**
- * retun input
- * can be file stream (-f), stringstream ( -- INPUT), or std::cin (none)
- **/
- std::basic_istream<char> &getInput() const;
- /**
- * false if invalid argument is passed
- **/
- bool isValid() const;
- /**
- * print usage
- * @param program name
- **/
- static void usage(const std::string &) noexcept;
- /**
- * get argv[0]
- **/
- const std::string &getProgName() const;
- /**
- * flags
- **/
- bool isStrict() const;
- bool colorEnabled() const;
- bool isIgnoringUnicode() const;
- private:
- /**
- * input stream
- * can be null for stdin
- **/
- std::basic_istream<char> *input;
- const std::string progName;
- std::list<std::string> params;
- bool ignoreUnicode;
- bool colorMode;
- bool strict;
- };
|