-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_buffer.h
49 lines (35 loc) · 1.15 KB
/
string_buffer.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
#ifndef AZURE_IOTC_LITE_STRING_BUFFER_H
#define AZURE_IOTC_LITE_STRING_BUFFER_H
namespace AzureIOT {
class StringBuffer {
char* data;
const char* immutable;
unsigned length;
public:
StringBuffer() : data(NULL), immutable(NULL), length(0) {}
StringBuffer(StringBuffer& buffer);
StringBuffer(const char* str, unsigned int lengthStr, bool isCopy = true);
StringBuffer(unsigned lengthStr);
void initialize(const char* str, unsigned lengthStr);
void alloc(unsigned lengthStr);
void set(unsigned index, char c);
void clear();
~StringBuffer();
char* operator*() { return data; }
unsigned getLength() { return length; }
void setLength(unsigned l);
bool startsWith(const char* str, size_t len);
int32_t indexOf(const char* look_for, size_t look_for_length,
int32_t start_index = 0);
#if defined(__MBED__) || defined(ARDUINO)
bool hash(const char* key, unsigned key_length);
#endif
bool urlDecode();
bool urlEncode();
bool base64Decode();
bool base64Encode();
};
} // namespace AzureIOT
#endif // AZURE_IOTC_LITE_STRING_BUFFER_H