Advertisement
Guest User

Untitled

a guest
Jul 10th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.44 KB | None | 0 0
  1. # HG changeset patch
  2. # User Marko Njezic
  3. # Date 1341910409 -7200
  4. # Node ID 5289c46f7a2573c4ac1a5605fc9eee002dff5aeb
  5. # Parent  28f80b03c96c0a06b575257a4bcd21ab351a2d48
  6. Add removal methods to ease manipulation.
  7.  
  8. diff -r 28f80b03c96c -r 5289c46f7a25 lexlib/CharacterSet.h
  9. --- a/lexlib/CharacterSet.h Tue Jul 10 16:58:14 2012 +1000
  10. +++ b/lexlib/CharacterSet.h Tue Jul 10 10:53:29 2012 +0200
  11. @@ -16,6 +16,19 @@
  12.     int size;
  13.     bool valueAfter;
  14.     bool *bset;
  15. +   void Change(int val, bool inSet) {
  16. +       assert(val >= 0);
  17. +       assert(val < size);
  18. +       bset[val] = inSet;
  19. +   }
  20. +   void ChangeString(const char *setToChange, bool inSet) {
  21. +       for (const char *cp=setToChange; *cp; cp++) {
  22. +           int val = static_cast<unsigned char>(*cp);
  23. +           assert(val >= 0);
  24. +           assert(val < size);
  25. +           bset[val] = inSet;
  26. +       }
  27. +   }
  28.  public:
  29.     enum setBase {
  30.         setNone=0,
  31. @@ -67,17 +80,16 @@
  32.         return *this;
  33.     }
  34.     void Add(int val) {
  35. -       assert(val >= 0);
  36. -       assert(val < size);
  37. -       bset[val] = true;
  38. +       Change(val, true);
  39.     }
  40.     void AddString(const char *setToAdd) {
  41. -       for (const char *cp=setToAdd; *cp; cp++) {
  42. -           int val = static_cast<unsigned char>(*cp);
  43. -           assert(val >= 0);
  44. -           assert(val < size);
  45. -           bset[val] = true;
  46. -       }
  47. +       ChangeString(setToAdd, true);
  48. +   }
  49. +   void Remove(int val) {
  50. +       Change(val, false);
  51. +   }
  52. +   void RemoveString(const char *setToRemove) {
  53. +       ChangeString(setToRemove, false);
  54.     }
  55.     bool Contains(int val) const {
  56.         assert(val >= 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement