MCPcopy Create free account
hub / github.com/catboost/catboost / WriteGuidToBuffer

Function WriteGuidToBuffer

library/cpp/yt/misc/guid.cpp:144–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144char* WriteGuidToBuffer(char* ptr, TGuid value)
145{
146 auto writeHex1 = [&] (ui8 x) {
147 *ptr = HexDigits1[x];
148 ptr += 1;
149 };
150
151 auto writeHex2 = [&] (ui8 x) {
152 ::memcpy(ptr, &HexDigits2[x], 2);
153 ptr += 2;
154 };
155
156 auto writeComponent = [&] (ui32 x) {
157 /* */ if (x >= 0x10000000) {
158 writeHex2((x >> 24) & 0xff);
159 writeHex2((x >> 16) & 0xff);
160 writeHex2((x >> 8) & 0xff);
161 writeHex2( x & 0xff);
162 } else if (x >= 0x1000000) {
163 writeHex1( x >> 24);
164 writeHex2((x >> 16) & 0xff);
165 writeHex2((x >> 8) & 0xff);
166 writeHex2( x & 0xff);
167 } else if (x >= 0x100000) {
168 writeHex2((x >> 16) & 0xff);
169 writeHex2((x >> 8) & 0xff);
170 writeHex2( x & 0xff);
171 } else if (x >= 0x10000) {
172 writeHex1( x >> 16);
173 writeHex2((x >> 8) & 0xff);
174 writeHex2( x & 0xff);
175 } else if (x >= 0x1000) {
176 writeHex2( x >> 8);
177 writeHex2( x & 0xff);
178 } else if (x >= 0x100) {
179 writeHex1( x >> 8);
180 writeHex2( x & 0xff);
181 } else if (x >= 0x10) {
182 writeHex2( x);
183 } else {
184 writeHex1( x);
185 }
186 };
187
188 auto writeDash = [&] () {
189 *ptr++ = '-';
190 };
191
192 writeComponent(value.Parts32[3]);
193 writeDash();
194 writeComponent(value.Parts32[2]);
195 writeDash();
196 writeComponent(value.Parts32[1]);
197 writeDash();
198 writeComponent(value.Parts32[0]);
199
200 return ptr;
201}

Callers 3

TFormattableGuidMethod · 0.85
FormatValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected