sedCommand.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Filename: sedCommand.h
  2. // Created by: drose (24Oct00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef SEDCOMMAND_H
  6. #define SEDCOMMAND_H
  7. #include "ppremake.h"
  8. #include <sys/types.h>
  9. #ifdef HAVE_REGEX_H
  10. #include <regex.h>
  11. #else
  12. #include "gnu_regex.h"
  13. #endif
  14. class SedScript;
  15. class SedContext;
  16. class SedAddress;
  17. ///////////////////////////////////////////////////////////////////
  18. // Class : SedCommand
  19. // Description : This represents a single command (of several
  20. // possible, separated by semicolons) to a SedProgram.
  21. ////////////////////////////////////////////////////////////////////
  22. class SedCommand {
  23. public:
  24. SedCommand();
  25. ~SedCommand();
  26. bool parse_command(const string &line, size_t &p);
  27. void run(SedScript &script, SedContext &context);
  28. private:
  29. bool parse_s_params(const string &line, size_t &p);
  30. void do_command(SedScript &script, SedContext &context);
  31. void do_s_command(SedContext &context);
  32. SedAddress *_addr1;
  33. SedAddress *_addr2;
  34. char _command;
  35. string _text;
  36. regex_t _re;
  37. string _string1;
  38. string _string2;
  39. enum Flags {
  40. F_have_re = 0x001,
  41. F_g = 0x002,
  42. };
  43. int _flags;
  44. bool _active;
  45. };
  46. #endif