sedAddress.h 998 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Filename: sedAddress.h
  2. // Created by: drose (24Oct00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef SEDADDRESS_H
  6. #define SEDADDRESS_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 SedContext;
  15. ///////////////////////////////////////////////////////////////////
  16. // Class : SedAddress
  17. // Description : This represents a single address in a sed command,
  18. // something like a line number or a regular expression.
  19. ////////////////////////////////////////////////////////////////////
  20. class SedAddress {
  21. public:
  22. SedAddress();
  23. ~SedAddress();
  24. bool parse_address(const string &line, size_t &p);
  25. bool matches(const SedContext &context) const;
  26. bool precedes(const SedContext &context) const;
  27. private:
  28. enum AddressType {
  29. AT_invalid,
  30. AT_numeric,
  31. AT_last,
  32. AT_re,
  33. };
  34. AddressType _address_type;
  35. int _number;
  36. regex_t _re;
  37. };
  38. #endif