Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate streaming operators for std::ostream #467

Closed
trittsv opened this issue Jan 24, 2024 · 3 comments · Fixed by #472
Closed

Generate streaming operators for std::ostream #467

trittsv opened this issue Jan 24, 2024 · 3 comments · Fixed by #472
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@trittsv
Copy link
Contributor

trittsv commented Jan 24, 2024

It is a common task to somehow log the received samples.
For this std::ostream streaming operators are needed which are currently (v0.10.4) not generated from the .idl files.
Other Vendors do also generate streaming operators, for cyclone we have to manually create them currently.

So every datatype shall have a streaming operator.

Examples

// Stream all class members
std::ostream& operator<<(std::ostream& s, T_TextMarkupSupportedType const& rhs)
{
    return s << "["
             << "A_boldSupported: " << (rhs.A_boldSupported())
             << ", A_italicSupported: " << (rhs.A_italicSupported())
             << ", A_strikethroughSupported: " << (rhs.A_strikethroughSupported())
             << ", A_highlightSupported: " << (rhs.A_highlightSupported())
             << ", A_boldAndItalicSupported: " << (rhs.A_boldAndItalicSupported())
             << ", A_specialCharactersSupported: " << (rhs.A_specialCharactersSupported())
             << "]";
}

// Stream enums
std::ostream& operator<<(std::ostream& s, T_HorizontalAlignmentType const& rhs)
{
    switch (rhs)
    {
        case P_Display_Extension_PSM::T_HorizontalAlignmentType::L_HorizontalAlignment__Invalid:
            s << "T_HorizontalAlignmentType::L_HorizontalAlignment__Invalid"; break;
        case P_Display_Extension_PSM::T_HorizontalAlignmentType::L_HorizontalAlignment__Default:
            s << "T_HorizontalAlignmentType::L_HorizontalAlignment__Default"; break;
        case P_Display_Extension_PSM::T_HorizontalAlignmentType::L_HorizontalAlignment__Left:
            s << "T_HorizontalAlignmentType::L_HorizontalAlignment__Left"; break;
        case P_Display_Extension_PSM::T_HorizontalAlignmentType::L_HorizontalAlignment__Centre:
            s << "T_HorizontalAlignmentType::L_HorizontalAlignment__Centre"; break;
        case P_Display_Extension_PSM::T_HorizontalAlignmentType::L_HorizontalAlignment__Right:
            s << "T_HorizontalAlignmentType::L_HorizontalAlignment__Right"; break;
        default: break;
    }
    return s;
}
@eboasson
Copy link
Contributor

I think it is a worthwhile thing to generate these, and it is quite straightforward, too. Unfortunately, I don't think I'll get around to it anytime soon, but perhaps someone else feels up to the challenge?

@eboasson eboasson added enhancement New feature or request good first issue Good for newcomers labels Jan 30, 2024
@trittsv
Copy link
Contributor Author

trittsv commented Jan 30, 2024

I will implement it 🙂

@trittsv
Copy link
Contributor Author

trittsv commented Feb 27, 2024

Hi @eboasson its implemented and the PR #472 is ready for review.
Would be great if you could have a look into it 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants