~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/inc/Puma/DString.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __DString_h__
20
20
#define __DString_h__
21
21
 
 
22
/** \file
 
23
 *  Global hash table based string container. */
 
24
 
22
25
#include "StrHashTable.h"
23
26
#include <assert.h>
24
27
 
25
28
namespace Puma {
26
29
 
27
30
 
 
31
/** Global string hash table used by Puma::DString. */
28
32
extern StrHashTable ___str_dict;
29
33
 
 
34
 
 
35
/** \class DString DString.h Puma/DString.h
 
36
 *  Global hash table based string container. */
30
37
class DString {
31
38
  StrHashKey *m_Key;
32
39
 
33
40
public:
 
41
  /** Constructor. */
34
42
  DString () {
35
43
    m_Key = ___str_dict.empty ();
36
44
    assert (m_Key);
37
45
  }
 
46
  /** Constructor.
 
47
   *  \param s The string, is put into the hash table. */
38
48
  DString (const char *s) {
39
49
    if(s == 0) {
40
50
      m_Key = ___str_dict.empty ();
43
53
    }
44
54
    assert (m_Key);
45
55
  }
 
56
  /** Copy constructor.
 
57
   *  \param s The string to copy. */
46
58
  DString (const DString &s) : m_Key (s.m_Key) {
47
59
    assert (s.m_Key);
48
60
  }
 
61
  /** Destructor. */
 
62
  ~DString () {
 
63
    m_Key = 0;
 
64
  }
49
65
  
 
66
  /** Assignment operator.
 
67
   *  \param s The string to copy. */
50
68
  DString &operator = (const DString &s) {
51
69
    assert (s.m_Key);
52
70
    m_Key = s.m_Key;
53
71
    return *this;
54
72
  }
55
73
  
 
74
  /** Assignment operator.
 
75
   *  \param s The string to copy. */
56
76
  DString &operator = (const char *s) {
57
77
    if(s == 0) {
58
78
      m_Key = ___str_dict.empty ();
63
83
    return *this;
64
84
  }
65
85
 
 
86
  /** Check if the given string equals this string.
 
87
   *  \param s The string to compare with. */
66
88
  bool operator == (const DString &s) const { 
67
89
    assert (m_Key && s.m_Key);
68
90
    return m_Key == s.m_Key; 
69
91
  }
 
92
  /** Check if the given string not equals this string.
 
93
   *  \param s The string to compare with. */
70
94
  bool operator != (const DString &s) const { 
71
95
    assert (m_Key && s.m_Key);
72
96
    return m_Key != s.m_Key; 
73
97
  }
74
98
 
 
99
  /** Get the contained C string. */
75
100
  const char *c_str() const { 
76
101
    assert (m_Key);
77
102
    return m_Key->c_str (); 
78
103
  }
 
104
  /** Get the length of the string. */
79
105
  unsigned int length () const { 
80
106
    assert (m_Key);
81
107
    return m_Key->length (); 
82
108
  }
 
109
  /** Check if the string is empty (length=0). */
83
110
  bool empty () const {
84
111
    assert (m_Key);
85
112
    return m_Key->length () == 0;
86
113
  }
 
114
  /** Get the magic number of the string. */
87
115
  unsigned int magic () const { 
88
116
    assert (m_Key);
89
117
    return m_Key->getMagic (); 
90
118
  }
91
119
 
 
120
  /** Get the contained C string. */
92
121
  operator const char *() const {
93
122
    assert (m_Key);
94
123
    return c_str ();
95
124
  }
96
125
  
 
126
  /** Clear the global string hash table. */
97
127
  static void clearDict() {
98
128
    ___str_dict.clear ();
99
129
  }