daeStringTable.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the MIT Open Source License, for details please see license.txt or the website
  5. * http://www.opensource.org/licenses/mit-license.php
  6. *
  7. */
  8. #ifndef __DAE_STRING_TABLE_H__
  9. #define __DAE_STRING_TABLE_H__
  10. #include <dae/daeTypes.h>
  11. #include <dae/daeMemorySystem.h>
  12. /**
  13. * The @c daeStringTable is a simple string table class to hold a float list of strings
  14. * without a lot of allocations.
  15. */
  16. class daeStringTable
  17. {
  18. public: // allocate/construct/destruct/deallocate
  19. /**
  20. * Macro that defines new and delete overrides for this class
  21. */
  22. DAE_ALLOC
  23. /**
  24. * Constructor which specifies fixed buffer size.
  25. * @param stringBufferSize The size of the buffer to create for string allocation.
  26. */
  27. DLLSPEC daeStringTable(int stringBufferSize = 1024*1024);
  28. /**
  29. * Destructor.
  30. */
  31. ~daeStringTable() { clear(); }
  32. public: // INTERFACE
  33. /**
  34. * Allocates a string from the table.
  35. * @param string <tt> const char * </tt> to copy into the table.
  36. * @return Returns an allocated string.
  37. */
  38. DLLSPEC daeString allocString(daeString string);
  39. /**
  40. * Clears the storage.
  41. */
  42. DLLSPEC void clear();
  43. private: // MEMBERS
  44. size_t _stringBufferSize;
  45. size_t _stringBufferIndex;
  46. daeStringArray _stringBuffersList;
  47. daeString allocateBuffer();
  48. daeString _empty;
  49. };
  50. #endif //__DAE_STRING_TABLE_H__