src/misc/blob.hpp
branchNewGRF_ports
changeset 10724 68a692eacf22
parent 6872 1c4a4a609f85
child 10994 cd9968b6f96b
equal deleted inserted replaced
10349:ff900a23e102 10724:68a692eacf22
     1 /* $Id$ */
     1 /* $Id$ */
     2 
     2 
     3 /** @file blob.hpp */
     3 /** @file blob.hpp Support for storing random binary data. */
     4 
     4 
     5 #ifndef BLOB_HPP
     5 #ifndef BLOB_HPP
     6 #define BLOB_HPP
     6 #define BLOB_HPP
     7 
     7 
     8 #include "../core/alloc_func.hpp"
     8 #include "../core/alloc_func.hpp"
   371 	{
   371 	{
   372 		Free();
   372 		Free();
   373 	}
   373 	}
   374 
   374 
   375 	/** Check the validity of item index (only in debug mode) */
   375 	/** Check the validity of item index (only in debug mode) */
   376 	FORCEINLINE void CheckIdx(bsize_t idx)
   376 	FORCEINLINE void CheckIdx(bsize_t idx) const
   377 	{
   377 	{
   378 		assert(idx >= 0); assert(idx < Size());
   378 		assert(idx >= 0); assert(idx < Size());
   379 	}
   379 	}
   380 
   380 
   381 	/** Return pointer to the first data item - non-const version */
   381 	/** Return pointer to the first data item - non-const version */
   398 	}
   398 	}
   399 
   399 
   400 	/** Return pointer to the idx-th data item - const version */
   400 	/** Return pointer to the idx-th data item - const version */
   401 	FORCEINLINE const Titem* Data(bsize_t idx) const
   401 	FORCEINLINE const Titem* Data(bsize_t idx) const
   402 	{
   402 	{
   403 		CheckIdx(idx); return (Data() + idx);
   403 		CheckIdx(idx);
       
   404 		return (Data() + idx);
   404 	}
   405 	}
   405 
   406 
   406 	/** Return number of items in the Blob */
   407 	/** Return number of items in the Blob */
   407 	FORCEINLINE bsize_t Size() const
   408 	FORCEINLINE bsize_t Size() const
   408 	{
   409 	{