libscid 0.1.0
Chess applications made easy.
Loading...
Searching...
No Matches
dstring.h
Go to the documentation of this file.
1
5#pragma once
6
8
9#include <cstddef>
10#include <cstdio>
11#include <string>
12
13namespace scid::core {
14
15class DString { // DEPRECATED
16 std::string s_;
17
18public:
19 void Clear() { s_.clear(); }
20
21 const char* Data() { return s_.c_str(); }
22
23 size_t Length(void) { return s_.size(); }
24
25 void AddChar(char ch) { s_.append(1, ch); }
26
27 void AppendUint(uint i) {
28 char s[16];
29 std::snprintf(s, sizeof(s), "%u", i);
30 s_.append(s);
31 }
32
33 void AppendInt(int i) {
34 char s[16];
35 std::snprintf(s, sizeof(s), "%d", i);
36 s_.append(s);
37 }
38
39 void Append(uint i) { AppendUint(i); }
40
41 void Append(const char* str) { s_.append(str); }
42
43 // To allow convenient appending of multiple strings without resorting
44 // to messy variable-length argument lists, we define DString::Append()
45 // for up to five string arguments, and for up to four arguments where
46 // one is an unsigned integer and the rest are strings.
47 void Append(const char* s1, const char* s2) {
48 Append(s1);
49 Append(s2);
50 }
51 void Append(const char* s1, uint i2) {
52 Append(s1);
53 Append(i2);
54 }
55 void Append(uint i1, const char* s2) {
56 Append(i1);
57 Append(s2);
58 }
59 void Append(const char* s1, const char* s2, const char* s3) {
60 Append(s1);
61 Append(s2);
62 Append(s3);
63 }
64 void Append(const char* s1, const char* s2, uint i3) {
65 Append(s1);
66 Append(s2);
67 Append(i3);
68 }
69 void Append(const char* s1, uint i2, const char* s3) {
70 Append(s1);
71 Append(i2);
72 Append(s3);
73 }
74 void Append(uint i1, const char* s2, const char* s3) {
75 Append(i1);
76 Append(s2);
77 Append(s3);
78 }
79 void Append(const char* s1, const char* s2, const char* s3,
80 const char* s4) {
81 Append(s1);
82 Append(s2);
83 Append(s3);
84 Append(s4);
85 }
86 void Append(const char* s1, const char* s2, const char* s3, uint i4) {
87 Append(s1);
88 Append(s2);
89 Append(s3);
90 Append(i4);
91 }
92 void Append(const char* s1, const char* s2, uint i3, const char* s4) {
93 Append(s1);
94 Append(s2);
95 Append(i3);
96 Append(s4);
97 }
98 void Append(const char* s1, uint i2, const char* s3, const char* s4) {
99 Append(s1);
100 Append(i2);
101 Append(s3);
102 Append(s4);
103 }
104 void Append(uint i1, const char* s2, const char* s3, const char* s4) {
105 Append(i1);
106 Append(s2);
107 Append(s3);
108 Append(s4);
109 }
110 void Append(const char* s1, const char* s2, const char* s3, const char* s4,
111 const char* s5) {
112 Append(s1);
113 Append(s2);
114 Append(s3);
115 Append(s4);
116 Append(s5);
117 }
118};
119
120
121} // namespace scid::core
Definition dstring.h:15
Constants and definitions of the chess board.