| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /**
- * params.hh for jsonstroller
- *
- * Author: isundil <isundill@gmail.com>
- **/
- #pragma once
- #include <map>
- #include <list>
- #include <string>
- #include <utility>
- #include <istream>
- #include "fifoMap.hpp"
- typedef fifoMap<std::string, std::basic_istream<char> *> IndexedDeque;
- 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;
- /**
- * true if need sorted object
- **/
- virtual bool sortObjects() const =0;
- };
- class Params: public AParams
- {
- public:
- Params(char **av);
- virtual ~Params();
- /**
- * Interpret input
- **/
- virtual bool read();
- /**
- * retun input
- * can be file stream (-f), stringstream ( -- INPUT), or std::cin (none)
- **/
- IndexedDeque getInputs() const;
- /**
- * false if invalid argument is passed
- **/
- bool isValid() const;
- /**
- * print usage
- * @param program name
- **/
- virtual void usage() const noexcept;
- /**
- * print version number
- * @param program name
- **/
- virtual void version() const noexcept;
- /**
- * get argv[0]
- **/
- const std::string &getProgName() const;
- /**
- * flags
- **/
- bool isStrict() const;
- bool colorEnabled() const;
- bool isIgnoringUnicode() const;
- bool isDiff() const;
- bool sortObjects() const;
- private:
- /**
- * input stream
- * can be null for stdin
- **/
- IndexedDeque inputs;
- const std::string progName;
- std::list<std::string> params;
- bool ignoreUnicode;
- bool colorMode;
- bool strict;
- bool diffMode;
- bool sorted;
- };
|