Skip to content

Commit

Permalink
Merge pull request #387 from jwillemsen/jwi-boundedstringsimplify
Browse files Browse the repository at this point in the history
Simplify bounded (w)string CDR support
  • Loading branch information
jwillemsen authored May 27, 2024
2 parents 40a5541 + a720905 commit 3d03d72
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 44 deletions.
9 changes: 2 additions & 7 deletions ridlbe/c++11/templates/cli/prx/string_cdr.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
//@}

Expand Down
25 changes: 0 additions & 25 deletions ridlbe/c++11/templates/cli/src/string_cdr.erb

This file was deleted.

3 changes: 3 additions & 0 deletions ridlbe/c++11/writers/stubproxyheader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 0 additions & 12 deletions ridlbe/c++11/writers/stubproxysource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions tao/x11/bounded_string_cdr_t.h
Original file line number Diff line number Diff line change
@@ -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 <typename _Tp>
struct taox11_string_cdr
{
/// Bounded insert
template <const uint32_t _Bound, typename _Stream>
static inline bool insert (
_Stream& _strm,
const TAOX11_IDL::bounded_string<_Bound>& _bstr)
{
return (_strm << ACE_OutputCDR::from_std_string (_bstr, _Bound));
}

template <const uint32_t _Bound, typename _Stream>
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 <const uint32_t _Bound, typename _Stream>
static bool extract (
_Stream& _strm,
TAOX11_IDL::bounded_string<_Bound>& _bstr)
{
return (_strm >> ACE_InputCDR::to_std_string (_bstr, _Bound));
}

template <const uint32_t _Bound, typename _Stream>
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
1 change: 1 addition & 0 deletions tao/x11/taox11.mpc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d03d72

Please sign in to comment.