MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / AppendAsString

Method AppendAsString

src/ObjectModel/ObjectModel.cpp:32–207  ·  view source on GitHub ↗

Append a string representation of this value to a string

Source from the content-addressed store, hash-verified

30
31// Append a string representation of this value to a string
32void ExpressionValue::AppendAsString(const StringRef& str) const noexcept
33{
34 switch (GetType())
35 {
36 case TypeCode::Char:
37 str.cat(cVal);
38 break;
39
40 case TypeCode::CString:
41 str.cat(sVal);
42 break;
43
44 case TypeCode::HeapString:
45 str.cat(shVal.Get().Ptr());
46 break;
47
48 case TypeCode::Float:
49 str.catf(GetFloatFormatString(), (double)fVal);
50 break;
51
52 case TypeCode::Uint32:
53 str.catf("%" PRIu32, uVal); // convert unsigned integer to string
54 break;
55
56 case TypeCode::Uint64:
57 str.catf("%" PRIu64, ((uint64_t)param << 32) | uVal); // convert unsigned integer to string
58 break;
59
60 case TypeCode::Int32:
61 str.catf("%" PRIi32, uVal); // convert signed integer to string
62 break;
63
64 case TypeCode::Bool:
65 str.cat((bVal) ? "true" : "false"); // convert bool to string
66 break;
67
68 case TypeCode::IPAddress_tc:
69 str.cat(IP4String(uVal).c_str());
70 break;
71
72 case TypeCode::None:
73 str.cat("null");
74 break;
75
76 case TypeCode::DateTime_tc:
77 {
78 const time_t tval = Get56BitValue();
79 tm timeInfo;
80 gmtime_r(&tval, &timeInfo);
81 str.catf("%04u-%02u-%02uT%02u:%02u:%02u",
82 timeInfo.tm_year + 1900, timeInfo.tm_mon + 1, timeInfo.tm_mday, timeInfo.tm_hour, timeInfo.tm_min, timeInfo.tm_sec);
83 }
84 break;
85
86 case TypeCode::Duration:
87 {
88 unsigned int hours = uVal/3600,
89 minutes = (uVal / 60) % 60,

Callers 8

THROWSFunction · 0.80
StringConcatMethod · 0.80
ConvertToStringMethod · 0.80
ProcessAbortCommandMethod · 0.80
THROWSFunction · 0.80
ValueMenuItem.cppFile · 0.80
WriteEvaluationResultMethod · 0.80

Calls 10

catMethod · 0.80
catfMethod · 0.80
AppendSysDirMethod · 0.80
AppendWebDirMethod · 0.80
GetNumElementsMethod · 0.80
GetElementMethod · 0.80
AppendPinNameMethod · 0.80
GetTypeFunction · 0.50
GetMethod · 0.45

Tested by

no test coverage detected