regexpr.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // regexpr.h
  19. #if defined(_MSC_VER)
  20. #pragma once
  21. #endif
  22. #ifndef REGEXPR_H
  23. #define REGEXPR_H
  24. /*
  25. ** RegularExpressionClass - This class encapsulates regular expression
  26. ** evaluation. It provides a nice and simple wrapper around the
  27. ** unfriendliness that is the GNU regex library. So try not to use
  28. ** gnu_regex.h anywhere, cause it'll make your code rather gross looking.
  29. **
  30. ** 10/12/2000 AJA - Initial Implementation
  31. **
  32. ** 01/02/2001 AJA - Added a quick regular expression tutorial to the project.
  33. ** You can find it in your wwlib directory in a file named
  34. ** "Regular Expression Tutorial.html". This file comes from the web at
  35. ** http://www.living-source.com/user/matte/regexp/regexp_tutorial.html
  36. */
  37. class RegularExpressionClass
  38. {
  39. public:
  40. RegularExpressionClass (const char *expression=0);
  41. RegularExpressionClass (const RegularExpressionClass &copy);
  42. ~RegularExpressionClass (void);
  43. // Before you try to match a string against this regular expression,
  44. // you must first compile the expression. This has the logical effect
  45. // of assigning the regular expression string to this
  46. // RegularExpressionClass object.
  47. // If you passed the expression into the constructor of this object,
  48. // Compile() was called for you. To ensure the compilation in the
  49. // constructor succeeded, check the return value of Is_Valid().
  50. // Compile() returns true if the compilation succeeded (ie. the given
  51. // expression string formed a valid regular expression).
  52. bool Compile (const char *expression);
  53. // Returns true if a valid regular expression has been assigned to
  54. // this object. If you passed a regular expression string into this
  55. // object's constructor, make sure you check Is_Valid before calling
  56. // Match().
  57. bool Is_Valid (void) const;
  58. // Tests if 'string' matches this regular expression.
  59. bool Match (const char *string) const;
  60. // Standard operators.
  61. RegularExpressionClass & operator = (const RegularExpressionClass &rhs);
  62. bool operator == (const RegularExpressionClass &rhs) const;
  63. bool operator != (const RegularExpressionClass &rhs) const;
  64. private:
  65. struct DataStruct;
  66. DataStruct *Data;
  67. };
  68. #endif