Home | History | Annotate | Download | only in dae
      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 
      9 #ifndef __DAE_STRING_TABLE_H__
     10 #define __DAE_STRING_TABLE_H__
     11 #include <dae/daeTypes.h>
     12 #include <dae/daeMemorySystem.h>
     13 
     14 /**
     15  * The @c daeStringTable is a simple string table class to hold a float list of strings
     16  * without a lot of allocations.
     17  */
     18 class daeStringTable
     19 {
     20 public: // allocate/construct/destruct/deallocate
     21 	/**
     22 	 * Macro that defines new and delete overrides for this class
     23 	 */
     24 	DAE_ALLOC
     25 	/**
     26 	 * Constructor which specifies fixed buffer size.
     27 	 * @param stringBufferSize The size of the buffer to create for string allocation.
     28 	 */
     29 	DLLSPEC daeStringTable(int stringBufferSize = 1024*1024);
     30 
     31 	/**
     32 	 * Destructor.
     33 	 */
     34 	~daeStringTable() { clear(); }
     35 
     36 public: // INTERFACE
     37 	/**
     38 	 * Allocates a string from the table.
     39 	 * @param string <tt> const char * </tt> to copy into the table.
     40 	 * @return Returns an allocated string.
     41 	 */
     42 	DLLSPEC daeString allocString(daeString string);
     43 
     44 	/**
     45 	 * Clears the storage.
     46 	 */
     47 	DLLSPEC void clear();
     48 
     49 private: // MEMBERS
     50 	size_t _stringBufferSize;
     51 	size_t _stringBufferIndex;
     52 	daeStringArray _stringBuffersList;
     53 
     54 	daeString allocateBuffer();
     55 
     56 	daeString _empty;
     57 };
     58 
     59 #endif //__DAE_STRING_TABLE_H__
     60