daeStringTable.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef __DAE_STRING_TABLE_H__
  14. #define __DAE_STRING_TABLE_H__
  15. #include <dae/daeTypes.h>
  16. #include <dae/daeMemorySystem.h>
  17. /**
  18. * The @c daeStringTable is a simple string table class to hold a float list of strings
  19. * without a lot of allocations.
  20. */
  21. class daeStringTable
  22. {
  23. public: // allocate/construct/destruct/deallocate
  24. /**
  25. * Macro that defines new and delete overrides for this class
  26. */
  27. DAE_ALLOC
  28. /**
  29. * Constructor which specifies fixed buffer size.
  30. * @param stringBufferSize The size of the buffer to create for string allocation.
  31. */
  32. DLLSPEC daeStringTable(int stringBufferSize = 1024*1024);
  33. /**
  34. * Destructor.
  35. */
  36. ~daeStringTable() { clear(); }
  37. public: // INTERFACE
  38. /**
  39. * Allocates a string from the table.
  40. * @param string <tt> const char * </tt> to copy into the table.
  41. * @return Returns an allocated string.
  42. */
  43. DLLSPEC daeString allocString(daeString string);
  44. /**
  45. * Clears the storage.
  46. */
  47. DLLSPEC void clear();
  48. private: // MEMBERS
  49. size_t _stringBufferSize;
  50. size_t _stringBufferIndex;
  51. daeStringArray _stringBuffersList;
  52. daeString allocateBuffer();
  53. daeString _empty;
  54. };
  55. #endif //__DAE_STRING_TABLE_H__