Iterate Over Struct; Easily Display Struct Fields And Values In a RichEdit Box

后端 未结 9 1886
离开以前
离开以前 2020-12-13 22:10

Is there an easier way to display the struct fields and their corresponding values in RichEdit control?

This is what I am doing now:

<
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 22:26

    I suggest creating templated methods for writing to the text box:

    template 
    void
    Write_To_Textbox(const T& variable,
                     const std::string& variable_name,
                     TRichTextEdit & textbox)
    {
      //...
    }
    

    Then use some cut, copy, paste, and regular expression capable replacement editor functions and create an "annotate" function:

    void
    annotate(TRichTextEdit& textbox)
    {
      Write_To_Textbox(member1, "member1", textbox);
    //...
    }
    

    Note: Check syntax of template functions, as I don't think I got it right in this example.

提交回复
热议问题