1 #ifndef XIVELY_DATASTREAM_H
2 #define XIVELY_DATASTREAM_H
7 #define DATASTREAM_STRING 0
8 #define DATASTREAM_BUFFER 1
9 #define DATASTREAM_INT 2
10 #define DATASTREAM_FLOAT 3
12 class XivelyDatastream : public Printable {
13 friend class XivelyClient;
21 XivelyDatastream(String& aId, int aType);
22 XivelyDatastream(char* aIdBuffer, int aIdBufferLength, int aType);
23 XivelyDatastream(char* aIdBuffer, int aIdBufferLength, int aType, char* aValueBuffer, int aValueBufferLength);
24 int updateValue(Stream& aStream);
25 void setInt(int aValue);
26 void setFloat(float aValue);
27 void setString(String& aValue);
28 void setBuffer(const char* aValue);
33 virtual size_t printTo(Print&) const;
35 int idLength() { return (_idType == DATASTREAM_STRING ? _idString.length() : strlen(_idBuffer._buffer)); };
36 char idChar(int idx) { return (_idType == DATASTREAM_STRING ? _idString[idx] : (idx > strlen(_idBuffer._buffer) ? '\0' : _idBuffer._buffer[idx])); };
37 // FIXME Only needed until readStringUntil is available in core
38 int timedRead(Stream& aStream);