diff --git a/ridlbe/c++11/templates/cli/prx/string_cdr.erb b/ridlbe/c++11/templates/cli/prx/string_cdr.erb index 8445986e..e8d6bf06 100644 --- a/ridlbe/c++11/templates/cli/prx/string_cdr.erb +++ b/ridlbe/c++11/templates/cli/prx/string_cdr.erb @@ -14,20 +14,15 @@ class TAOX11_NAMESPACE::Arg_Traits<<%= scoped_cxxtype %>> TAO_BEGIN_VERSIONED_NAMESPACE_DECL -/// CDR streaming methods for <%= scoped_cxxname %> -<%= stub_proxy_export_macro %>bool _cdr_in_<%= scoped_cxxname.scope_to_cxxname %> (TAO_OutputCDR &, const IDL::traits<<%= scoped_cxxtype %>>::value_type&); -<%= stub_proxy_export_macro %>bool _cdr_out_<%= scoped_cxxname.scope_to_cxxname %> (TAO_InputCDR &, IDL::traits<<%= scoped_cxxtype %>>::value_type&); -#define _ALIAS_<%= scoped_cxxname.scope_to_cxxname %>_CDR_OPS_IMPL_ - /// @name CDR streaming operator specializations for <%= scoped_cxxname %> //@{ inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const IDL::traits<<%= scoped_cxxtype %>>::value_type &v) { - return _cdr_in_<%= scoped_cxxname.scope_to_cxxname %> (cdr, v); + return taox11_string_cdr<<%= scoped_cxxtype %>::value_type>::insert<<%= bound %>U> (cdr, v); } inline TAO_CORBA::Boolean operator>> (TAO_InputCDR &cdr, IDL::traits<<%= scoped_cxxtype %>>::value_type& v) { - return _cdr_out_<%= scoped_cxxname.scope_to_cxxname %> (cdr, v); + return taox11_string_cdr<<%= scoped_cxxtype %>::value_type>::extract<<%= bound %>U> (cdr, v); } //@} diff --git a/ridlbe/c++11/templates/cli/src/string_cdr.erb b/ridlbe/c++11/templates/cli/src/string_cdr.erb deleted file mode 100644 index 9b6174ca..00000000 --- a/ridlbe/c++11/templates/cli/src/string_cdr.erb +++ /dev/null @@ -1,25 +0,0 @@ - -// generated from <%= ridl_template_path %> -#if defined(_ALIAS_<%= scoped_cxxname.scope_to_cxxname %>_CDR_OPS_IMPL_) -bool _cdr_in_<%= scoped_cxxname.scope_to_cxxname %> ( - TAO_OutputCDR &strm, - const IDL::traits<<%= scoped_cxxtype %>>::value_type &_bstr) -{ -% if is_wstring? - return (strm << ACE_OutputCDR::from_std_wstring (_bstr, <%= bound %>)); -% else - return (strm << ACE_OutputCDR::from_std_string (_bstr, <%= bound %>)); -% end -} - -bool _cdr_out_<%= scoped_cxxname.scope_to_cxxname %> ( - TAO_InputCDR &strm, - IDL::traits<<%= scoped_cxxtype %>>::value_type &_bstr) -{ -% if is_wstring? - return (strm >> ACE_InputCDR::to_std_wstring (_bstr, <%= bound %>)); -% else - return (strm >> ACE_InputCDR::to_std_string (_bstr, <%= bound %>)); -% end -} -#endif // _ALIAS_<%= scoped_cxxname.scope_to_cxxname %>_CDR_OPS_IMPL_ diff --git a/ridlbe/c++11/writers/stubproxyheader.rb b/ridlbe/c++11/writers/stubproxyheader.rb index d536362b..f28e91d1 100644 --- a/ridlbe/c++11/writers/stubproxyheader.rb +++ b/ridlbe/c++11/writers/stubproxyheader.rb @@ -225,6 +225,9 @@ def visit_typedef(node) when IDL::Type::Array add_include('tao/x11/array_cdr_t.h') unless params[:no_cdr_streaming] check_idl_type(idl_type) + when IDL::Type::String, + IDL::Type::WString + add_include('tao/x11/bounded_string_cdr_t.h') if idl_type.size.to_i.positive? && !params[:no_cdr_streaming] end end diff --git a/ridlbe/c++11/writers/stubproxysource.rb b/ridlbe/c++11/writers/stubproxysource.rb index a2f5ac0b..3a2e9122 100644 --- a/ridlbe/c++11/writers/stubproxysource.rb +++ b/ridlbe/c++11/writers/stubproxysource.rb @@ -174,18 +174,6 @@ def visit_bitset(node) visitor(BitsetVisitor).visit_cdr(node) end - - def visit_typedef(node) - return if node.is_local? || params[:no_cdr_streaming] - # nothing to do if this is just an alias for another defined type - return if node.idltype.is_a?(IDL::Type::ScopedName) || node.idltype.resolved_type.is_standard_type? - - idl_type = node.idltype.resolved_type - case idl_type - when IDL::Type::String, IDL::Type::WString - visitor(StringVisitor).visit_cdr(node) # only bounded, unbounded is standard_type - end - end end # StubProxySourceCDRWriter class StubProxySourceProxyImplWriter < StubProxySourceBaseWriter diff --git a/tao/x11/bounded_string_cdr_t.h b/tao/x11/bounded_string_cdr_t.h new file mode 100644 index 00000000..e707278c --- /dev/null +++ b/tao/x11/bounded_string_cdr_t.h @@ -0,0 +1,58 @@ +/** + * @file bounded_string_cdr_t.h + * @author Johnny Willemsen + * + * @brief x11 string marshaling templates + * + * @copyright Copyright (c) Remedy IT Expertise BV + */ + +#ifndef TAOX11_STRING_CDR_T_H_INCLUDED +#define TAOX11_STRING_CDR_T_H_INCLUDED + +#include "tao/x11/base/tao_corba.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + + /// Generic string CDR streaming helper template + template + struct taox11_string_cdr + { + /// Bounded insert + template + static inline bool insert ( + _Stream& _strm, + const TAOX11_IDL::bounded_string<_Bound>& _bstr) + { + return (_strm << ACE_OutputCDR::from_std_string (_bstr, _Bound)); + } + + template + static inline bool insert ( + _Stream& _strm, + const TAOX11_IDL::bounded_wstring<_Bound>& _bstr) + { + return (_strm << ACE_OutputCDR::from_std_wstring (_bstr, _Bound)); + } + + /// Bounded extract + template + static bool extract ( + _Stream& _strm, + TAOX11_IDL::bounded_string<_Bound>& _bstr) + { + return (_strm >> ACE_InputCDR::to_std_string (_bstr, _Bound)); + } + + template + static bool extract ( + _Stream& _strm, + TAOX11_IDL::bounded_wstring<_Bound>& _bstr) + { + return (_strm >> ACE_InputCDR::to_std_wstring (_bstr, _Bound)); + } + }; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif // TAOX11_STRING_CDR_T_H_INCLUDED diff --git a/tao/x11/taox11.mpc b/tao/x11/taox11.mpc index ee29a608..ab799f24 100644 --- a/tao/x11/taox11.mpc +++ b/tao/x11/taox11.mpc @@ -293,6 +293,7 @@ project(taox11) : taox11_defaults, taolib { base/bounded_string_t.h base/bounded_type_traits_t.h base/bounded_vector_t.h + bounded_string_cdr_t.h cdr_long_double.h corba.h dynamic_adapter.h