Arduino DLNA Server
Loading...
Searching...
No Matches
StringRegistry.h
Go to the documentation of this file.
1#pragma once
2#include "basic/Str.h"
3
4namespace tiny_dlna {
10 public:
12 const char* add(char* in) {
13 for (auto& str : strings) {
14 if (str.equals(in)) {
15 return str.c_str();
16 }
17 }
18 strings.push_back(in);
19 return strings[strings.size() - 1].c_str();
20 }
21
22 void clear() { strings.clear(); }
23
25 size_t count() { return strings.size();}
26
28 size_t size() {
29 size_t total = 0;
30 for (auto &str : strings){
31 total += str.length();
32 }
33 return total;
34 }
35
36 protected:
38};
39
40} // namespace tiny_dlna
Make sure that a string is stored only once.
Definition: StringRegistry.h:9
void clear()
Definition: StringRegistry.h:22
Vector< Str > strings
Definition: StringRegistry.h:37
size_t count()
Reports the number of strings.
Definition: StringRegistry.h:25
size_t size()
Reports the total size of all allocated strings.
Definition: StringRegistry.h:28
const char * add(char *in)
adds a string
Definition: StringRegistry.h:12
Vector implementation which provides the most important methods as defined by std::vector....
Definition: Vector.h:21
Definition: Allocator.h:6