MCPcopy Create free account
hub / github.com/SmingHub/Sming / toString

Method toString

Sming/Core/Data/Uuid.cpp:108–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108size_t Uuid::toString(char* buffer, size_t bufSize) const
109{
110 if(isFlashPtr(this)) {
111 return Uuid(*this).toString(buffer, bufSize);
112 }
113
114 if(buffer == nullptr || bufSize < stringSize) {
115 return 0;
116 }
117
118 auto set = [&](unsigned offset, uint32_t value, unsigned digits) {
119 ultoa_wp(value, &buffer[offset], 16, digits, '0');
120 };
121
122 // 2fac1234-31f8-11b4-a222-08002b34c003
123 // 0 9 14 19 24 36
124
125 set(0, time_low, 8);
126 buffer[8] = '-';
127 set(9, time_mid, 4);
128 buffer[13] = '-';
129 set(14, time_hi_and_version, 4);
130 buffer[18] = '-';
131 set(19, clock_seq_hi_and_reserved, 2);
132 set(21, clock_seq_low, 2);
133 buffer[23] = '-';
134
135 unsigned pos = 24;
136 for(unsigned i = 0; i < 6; ++i) {
137 buffer[pos++] = hexchar(node[i] >> 4);
138 buffer[pos++] = hexchar(node[i] & 0x0f);
139 }
140
141 return stringSize;
142}
143
144String Uuid::toString() const
145{

Callers 1

toStringFunction · 0.45

Calls 7

isFlashPtrFunction · 0.85
UuidClass · 0.85
ultoa_wpFunction · 0.85
hexcharFunction · 0.85
setLengthMethod · 0.80
toStringFunction · 0.70
beginMethod · 0.45

Tested by

no test coverage detected