mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 06:36:45 +00:00
dump helper
This commit is contained in:
parent
c590ffd289
commit
d624f2a9ce
File diff suppressed because it is too large
Load Diff
@ -1726,9 +1726,8 @@ def build_message_type(
|
|||||||
dump_impl += f" {dump[0]} "
|
dump_impl += f" {dump[0]} "
|
||||||
else:
|
else:
|
||||||
dump_impl += "\n"
|
dump_impl += "\n"
|
||||||
dump_impl += f' out.append("{desc.name} {{\\n");\n'
|
dump_impl += f' MessageDumpHelper helper(out, "{desc.name}");\n'
|
||||||
dump_impl += indent("\n".join(dump)) + "\n"
|
dump_impl += indent("\n".join(dump)) + "\n"
|
||||||
dump_impl += ' out.append("}");\n'
|
|
||||||
else:
|
else:
|
||||||
o2 = f'out.append("{desc.name} {{}}");'
|
o2 = f'out.append("{desc.name} {{}}");'
|
||||||
if len(dump_impl) + len(o2) + 3 < 120:
|
if len(dump_impl) + len(o2) + 3 < 120:
|
||||||
@ -2095,6 +2094,19 @@ static inline void append_with_newline(std::string &out, const char *str) {
|
|||||||
out.append("\\n");
|
out.append("\\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RAII helper for message dump formatting
|
||||||
|
class MessageDumpHelper {
|
||||||
|
public:
|
||||||
|
MessageDumpHelper(std::string &out, const char *message_name) : out_(out) {
|
||||||
|
out_.append(message_name);
|
||||||
|
out_.append(" {\\n");
|
||||||
|
}
|
||||||
|
~MessageDumpHelper() { out_.append(" }"); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string &out_;
|
||||||
|
};
|
||||||
|
|
||||||
// Helper functions to reduce code duplication in dump methods
|
// Helper functions to reduce code duplication in dump methods
|
||||||
static void dump_field(std::string &out, const char *field_name, int32_t value, int indent = 2) {
|
static void dump_field(std::string &out, const char *field_name, int32_t value, int indent = 2) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user