Tokenizer.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* libs/opengles/Tokenizer.h
  2. **
  3. ** Copyright 2006, The Android Open Source Project
  4. **
  5. ** Licensed under the Apache License, Version 2.0 (the "License");
  6. ** you may not use this file except in compliance with the License.
  7. ** You may obtain a copy of the License at
  8. **
  9. ** http://www.apache.org/licenses/LICENSE-2.0
  10. **
  11. ** Unless required by applicable law or agreed to in writing, software
  12. ** distributed under the License is distributed on an "AS IS" BASIS,
  13. ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. ** See the License for the specific language governing permissions and
  15. ** limitations under the License.
  16. */
  17. #ifndef ANDROID_OPENGLES_TOKENIZER_H
  18. #define ANDROID_OPENGLES_TOKENIZER_H
  19. #include <utils/Vector.h>
  20. #include <utils/Errors.h>
  21. // ----------------------------------------------------------------------------
  22. namespace android {
  23. class Tokenizer
  24. {
  25. public:
  26. Tokenizer();
  27. Tokenizer(const Tokenizer& other);
  28. ~Tokenizer();
  29. uint32_t acquire();
  30. status_t reserve(uint32_t token);
  31. status_t release(uint32_t token);
  32. bool isAcquired(uint32_t token) const;
  33. void dump() const;
  34. struct run_t {
  35. run_t() {};
  36. run_t(uint32_t f, uint32_t l) : first(f), length(l) {}
  37. uint32_t first;
  38. uint32_t length;
  39. };
  40. private:
  41. ssize_t _indexOrderOf(uint32_t token, size_t* order=0) const;
  42. ssize_t _insertTokenAt(uint32_t token, size_t index);
  43. Vector<run_t> mRanges;
  44. };
  45. }; // namespace android
  46. // ----------------------------------------------------------------------------
  47. #endif // ANDROID_OPENGLES_TOKENIZER_H