util/StaticFifoBuffer: fix indent
This commit is contained in:
		| @@ -46,87 +46,87 @@ | ||||
| template<class T, size_t size> | ||||
| class StaticFifoBuffer { | ||||
| public: | ||||
|   typedef size_t size_type; | ||||
| 	typedef size_t size_type; | ||||
|  | ||||
| public: | ||||
|   typedef WritableBuffer<T> Range; | ||||
| 	typedef WritableBuffer<T> Range; | ||||
|  | ||||
| protected: | ||||
|   size_type head, tail; | ||||
|   T data[size]; | ||||
| 	size_type head, tail; | ||||
| 	T data[size]; | ||||
|  | ||||
| public: | ||||
|   constexpr | ||||
|   StaticFifoBuffer():head(0), tail(0) {} | ||||
| 	constexpr | ||||
| 	StaticFifoBuffer():head(0), tail(0) {} | ||||
|  | ||||
| protected: | ||||
|   void Shift() { | ||||
|     if (head == 0) | ||||
|       return; | ||||
| 	void Shift() { | ||||
| 		if (head == 0) | ||||
| 			return; | ||||
|  | ||||
|     assert(head <= size); | ||||
|     assert(tail <= size); | ||||
|     assert(tail >= head); | ||||
| 		assert(head <= size); | ||||
| 		assert(tail <= size); | ||||
| 		assert(tail >= head); | ||||
|  | ||||
|     std::move(data + head, data + tail, data); | ||||
| 		std::move(data + head, data + tail, data); | ||||
|  | ||||
|     tail -= head; | ||||
|     head = 0; | ||||
|   } | ||||
| 		tail -= head; | ||||
| 		head = 0; | ||||
| 	} | ||||
|  | ||||
| public: | ||||
|   void Clear() { | ||||
|     head = tail = 0; | ||||
|   } | ||||
| 	void Clear() { | ||||
| 		head = tail = 0; | ||||
| 	} | ||||
|  | ||||
|   bool IsEmpty() const { | ||||
|     return head == tail; | ||||
|   } | ||||
| 	bool IsEmpty() const { | ||||
| 		return head == tail; | ||||
| 	} | ||||
|  | ||||
|   bool IsFull() const { | ||||
|     return head == 0 && tail == size; | ||||
|   } | ||||
| 	bool IsFull() const { | ||||
| 		return head == 0 && tail == size; | ||||
| 	} | ||||
|  | ||||
|   /** | ||||
|    * Prepares writing.  Returns a buffer range which may be written. | ||||
|    * When you are finished, call append(). | ||||
|    */ | ||||
|   Range Write() { | ||||
|     Shift(); | ||||
|     return Range(data + tail, size - tail); | ||||
|   } | ||||
| 	/** | ||||
| 	 * Prepares writing.  Returns a buffer range which may be written. | ||||
| 	 * When you are finished, call append(). | ||||
| 	 */ | ||||
| 	Range Write() { | ||||
| 		Shift(); | ||||
| 		return Range(data + tail, size - tail); | ||||
| 	} | ||||
|  | ||||
|   /** | ||||
|    * Expands the tail of the buffer, after data has been written to | ||||
|    * the buffer returned by write(). | ||||
|    */ | ||||
|   void Append(size_type n) { | ||||
|     assert(tail <= size); | ||||
|     assert(n <= size); | ||||
|     assert(tail + n <= size); | ||||
| 	/** | ||||
| 	 * Expands the tail of the buffer, after data has been written to | ||||
| 	 * the buffer returned by write(). | ||||
| 	 */ | ||||
| 	void Append(size_type n) { | ||||
| 		assert(tail <= size); | ||||
| 		assert(n <= size); | ||||
| 		assert(tail + n <= size); | ||||
|  | ||||
|     tail += n; | ||||
|   } | ||||
| 		tail += n; | ||||
| 	} | ||||
|  | ||||
|   /** | ||||
|    * Return a buffer range which may be read.  The buffer pointer is | ||||
|    * writable, to allow modifications while parsing. | ||||
|    */ | ||||
|   Range Read() { | ||||
|     return Range(data + head, tail - head); | ||||
|   } | ||||
| 	/** | ||||
| 	 * Return a buffer range which may be read.  The buffer pointer is | ||||
| 	 * writable, to allow modifications while parsing. | ||||
| 	 */ | ||||
| 	Range Read() { | ||||
| 		return Range(data + head, tail - head); | ||||
| 	} | ||||
|  | ||||
|   /** | ||||
|    * Marks a chunk as consumed. | ||||
|    */ | ||||
|   void Consume(size_type n) { | ||||
|     assert(tail <= size); | ||||
|     assert(head <= tail); | ||||
|     assert(n <= tail); | ||||
|     assert(head + n <= tail); | ||||
| 	/** | ||||
| 	 * Marks a chunk as consumed. | ||||
| 	 */ | ||||
| 	void Consume(size_type n) { | ||||
| 		assert(tail <= size); | ||||
| 		assert(head <= tail); | ||||
| 		assert(n <= tail); | ||||
| 		assert(head + n <= tail); | ||||
|  | ||||
|     head += n; | ||||
|   } | ||||
| 		head += n; | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann