1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#ifndef INCLUDED_EXPR_
#define INCLUDED_EXPR_
#include <string>
#include <vector>
#include <memory>
#include "../enums/enums.h"
#include "../specbase/specbase.h"
// Expr syntax: letter [not] regex
namespace FBB
{
class OneKey;
class TempStream;
}
class Expr
{
size_t d_id;
static size_t s_id;
static bool s_interactive;
bool d_available; // set to true after regex()
// the handling mode of the regex
//int d_cinps; // (= Expr's letter argument)
eMatchMode d_matchMode;
std::string d_regex;
using UptrSpecBase = std::unique_ptr<SpecBase>;
// 0-ptrs or pointers to match objects
// derived from SpecBase
static std::vector<UptrSpecBase> s_matchPtr;
static std::unique_ptr<FBB::OneKey> s_oneKey;
static std::unique_ptr<FBB::TempStream> s_headers;
static std::unique_ptr<FBB::TempStream> s_input;
public:
Expr(eMatchMode matchMode);
size_t id() const;
bool regex(std::string const &txt);
bool matched(eTruth truth);
static bool interactive();
static void setInteractive(bool interactive);
static std::istream &input();
private:
bool match();
SpecBase *getMatchObject();
bool script(SpecBase &scriptObj);
static bool update(bool &var, eTruth truth);
};
// static
inline bool Expr::interactive()
{
return s_interactive;
}
inline size_t Expr::id() const
{
return d_id;
}
#endif
|