Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TransactionBufferReader.cpp « DuetNG « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b2788acbebbe464f1b550e46b1aad2ee26edf8f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * TransactionBufferReader.cpp
 *
 *  Created on: 7 Jul 2016
 *      Author: David
 */

#include "TransactionBufferReader.h"

TransactionBufferReader::TransactionBufferReader(TransactionBuffer& tb)
	: buf(tb), offset(0), ok(true)
{
}

const char* TransactionBufferReader::GetString(size_t fieldWidth)
{
	if (ok)
	{
		if (offset + fieldWidth <= buf.GetLength())
		{
			buf.EnsureNull(offset + fieldWidth - 1);
			const char* rslt = buf.GetData() + offset;
			offset += fieldWidth;
			return rslt;
		}
		ok = false;
	}
	return "**ERROR**";
}

// End