summaryrefslogtreecommitdiff
path: root/TAO/tao/params.cpp
blob: 44864877ae21a3863eb511fb7f87d9b141b927b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// $Id$

#include "tao/params.h"

#if !defined (__ACE_INLINE__)
# include "tao/params.i"
#endif /* __ACE_INLINE__ */

#include "tao/IOR_LookupTable.h"

ACE_RCSID(tao, params, "$Id$")

TAO_ORB_Parameters::TAO_ORB_Parameters (void)
  : name_service_port_ (0),
    trading_service_port_ (0),
    ior_lookup_table_ (0),
    sock_rcvbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ),
    sock_sndbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ),
    cdr_memcpy_tradeoff_ (ACE_DEFAULT_CDR_MEMCPY_TRADEOFF),
    use_lite_protocol_ (0)
{
}

TAO_ORB_Parameters::~TAO_ORB_Parameters (void)
{
  // Delete the table.
  delete this->ior_lookup_table_;
}

int 
TAO_ORB_Parameters::parse_endpoints (ACE_CString endpoints,
                                     TAO_EndpointSet endpoints_list)
{
  // Parse the string into seperate endpoints, where `endpoints' is of
  // the form:
  //
  //    protocol1:V.v//addr1,...,addrN/;protocol2:W.w//addr1,...,addrN/;...
  //
  // A single endpoint, instead of several, can be added just as well.

  const char endpoints_delimiter = ';';

  int length = endpoints.length ();

  if (endpoints[0] == endpoints_delimiter ||
      endpoints[length - 1] == endpoints_delimiter)
    {
      return -1;
      // Failure:  endpoints string has an empty endpoint at the beginning
      //           or the end of the string (e.g. ";uiop://foo;iiop:1.3//bar")
    }

  if (length > 0)
    {
      int endpoints_count = 1;

      for (size_t i = 0;
           i < ACE_static_cast (int, length);
           ++i)
        {
          if (endpoints[i] == endpoints_delimiter)
            endpoints_count++;
        }

      int begin = 0;
      int end = endpoints.find (endpoints_delimiter);

      for (int i = 1; i < endpoints_count; ++i)
        {
          if (end == 0)
            {
              // Handle case where two consecutive endpoints `;;'
              // delimiters are found within the endpoints set.
              //
              // Is it enough to just skip over it or should we return an
              // error?
              continue;
            }

          endpoints_list.insert (endpoints.substring (begin, end));
          // The substring call will work even if `end' is equal to
          // ACE_CString::npos since that will just extract the substring
          // from the offset `begin' to the end of the string.

          begin += end + 1;
          end = endpoints_list.find (endpoints_delimiter, begin);
        }

      return 0;  // Success
    }
  else
    {
      return -1;
      // Failure:  Empty string
    }
}


#if defined (ACE_EXPLICIT_TEMPLATE_INSTANTIATION)

template class ACE_Node<ACE_Cstring>;

template class ACE_Unbounded_Set<ACE_CString>;

template class ACE_Unbounded_Set_Iterator<ACE_CString, ACE_Null_Mutex>;

#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)

#pragma instantiate ACE_Node<ACE_Cstring>

#pragma instantiate ACE_Unbounded_Set<ACE_CString>

#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_CString, ACE_Null_Mutex>


#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */