PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/xhp/code_rope.hpp

http://github.com/facebook/xhp
C++ Header | 43 lines | 24 code | 4 blank | 15 comment | 0 complexity | 73f904b93c57fbebcb39b228e53d0b76 MD5 | raw file
Possible License(s): MIT, MPL-2.0-no-copyleft-exception
  1. /*
  2. +----------------------------------------------------------------------+
  3. | XHP |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 2009 - 2010 Facebook, Inc. (http://www.facebook.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE.PHP, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. */
  16. #include <ext/rope>
  17. #include <ext/pool_allocator.h>
  18. class code_rope {
  19. public:
  20. typedef __gnu_cxx::rope<char, __gnu_cxx::__pool_alloc<char> > _rope_t;
  21. protected:
  22. _rope_t str;
  23. size_t lf; /* how many line breaks this code contains */
  24. size_t no; /* line number this code starts on */
  25. public:
  26. code_rope(const _rope_t = "", const size_t = 0, const size_t = 0);
  27. code_rope(const code_rope&, const size_t = 0, const size_t = 0);
  28. const char* c_str() const;
  29. void prepend(const char* str);
  30. const char back() const;
  31. void pop_back();
  32. void strip_lines();
  33. size_t lineno() const;
  34. code_rope operator+(const code_rope& right) const;
  35. code_rope operator+(const char*) const;
  36. code_rope& operator=(const char*);
  37. friend code_rope operator+(const char*, const code_rope&);
  38. };
  39. code_rope operator+(const char*, const code_rope&);