summaryrefslogtreecommitdiff
path: root/ace/Local_Name_Space.h
blob: 728ac8afb1c93b313d04b715a0f818de088e46b0 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Local_Name_Space.h
 *
 *  $Id$
 *
 *  @author Prashant Jain (pjain@cs.wustl.edu)
 *  @author Irfan Pyarali (irfan@wuerl.wustl.edu)
 *  @author Douglas C. Schmidt (schmidt@cs.wustl.edu).
 */
//=============================================================================

#ifndef ACE_LOCAL_NAME_SPACE_H
#define ACE_LOCAL_NAME_SPACE_H

#include /**/ "ace/pre.h"

#include "ace/Malloc_T.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

class ACE_NS_WString;

/**
 * @class ACE_NS_String
 *
 * @brief This class and ACE_NS_Internal are used as Adapters to work
 * with the Map_Manager.
 *
 * In order to work correctly, this class must be able to
 * convert back and forth with <ACE_NS_WStrings>.
 */
class ACE_Export ACE_NS_String
{
public:
  // = Initialization.
  /// Default "no-op" constructor.
  ACE_NS_String (void);

  /// Initialization method.
  ACE_NS_String (ACE_WCHAR_T *dst,
                 const ACE_WCHAR_T *src,
                 size_t len);

  /// Converts an ACE_NS_WString to an ACE_NS_String;
  ACE_NS_String (const ACE_NS_WString &);

  /// Destructor
  ~ACE_NS_String (void);

  /// Converts an ACE_NS_String to fresh copy of an ACE_NS_WString;
  operator ACE_NS_WString () const;

  /// Return the ASCII character representation.
  char *char_rep (void) const;

  /// Matches on substrings.
  int strstr (const ACE_NS_String &) const;

  /// Compare an ACE_NS_String.
  bool operator == (const ACE_NS_String &) const;

  /// Compare an ACE_NS_String.
  bool operator != (const ACE_NS_String &) const;

  /// Returns length of the string
  size_t len (void) const;

  /// Returns the underlying representation.
  ACE_WCHAR_T *fast_rep (void) const;

  /// Returns a hash value for this string.
  u_long hash (void) const;

private:
  /// Length of the string.
  size_t len_;

  /// This actually points into shared/persistent memory.
  ACE_WCHAR_T *rep_;

  /// Should rep_ be deleted when destructed (only used
  /// for WString conversions)
  int delete_rep_;
};

/**
 * @class ACE_NS_Internal
 *
 * @brief This class and ACE_NS_String are used as Adapters to work
 * with the Map_Manager.
 */
class ACE_Export ACE_NS_Internal
{
public:
  /// No-op constructor.
  ACE_NS_Internal (void);

  /// Constructor.
  ACE_NS_Internal (ACE_NS_String &value, const char *type);

  /// Compare an ACE_NS_Internal
  bool operator == (const ACE_NS_Internal &) const;

  /// Return value.
  ACE_NS_String value (void);

  /// Return type.
  const char *type (void);

private:
  /// Contains the value of the string.
  ACE_NS_String value_;

  /// Contains the type of the string.
  const char *type_;
};

ACE_END_VERSIONED_NAMESPACE_DECL

// Include the ACE_Local_Name_Space templates stuff at this point.
#include "ace/Local_Name_Space_T.h"

#include /**/ "ace/post.h"

#endif /* ACE_LOCAL_NAME_SPACE_H */