Skip to content

Commit

Permalink
Add ostream formatting for optional
Browse files Browse the repository at this point in the history
    * ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb:
    * tests/idl4/optional/client.cpp:
    * tests/idl4/optional/test.idl:
  • Loading branch information
jwillemsen committed Jun 11, 2024
1 parent 56efa85 commit 6b9a431
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ struct formatter<<%= scoped_cxxtype %>, OStrm_>
% unless _m.optional? || _m.external?
<< "<%= _sep %><%= _m.cxxname %>=" << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ())
% else
%# TODO
%# << "<%= _sep %><%= _m.cxxname %>=" << (val_.<%= _m.cxxname() %> ().has_value () ? IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ().value ()) : "<empty>")
<< "<%= _sep %><%= _m.cxxname %>="; if (val_.<%= _m.cxxname() %> ().has_value ()) { os_ << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ().value ()); } else { os_ << "std::nullopt"; } os_
% end
% end
% _sep = ',' unless _sep
Expand Down
3 changes: 3 additions & 0 deletions tests/idl4/optional/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ int main (int /*argc*/, char* /*argv*/[])
bar mybar;

TAOX11_TEST_INFO << "mybar: " << mybar << std::endl;
mybar.z(6);
TAOX11_TEST_INFO << "mybar: " << mybar << std::endl;

return retval;
}
3 changes: 2 additions & 1 deletion tests/idl4/optional/test.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
struct bar
{
short x;
string y;
@optional short z;
long z_long;
@optional short a;
@optional string opt_string;
string y;
};

0 comments on commit 6b9a431

Please sign in to comment.