CTR Pia  4.11.3
Game Communication Engine
common_String.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_String.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/common/common_definitions.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace common
25 {
26 
27 
28 /*!
29 @brief Class for representing strings.
30 
31 @details This class includes a 128-byte buffer used to store strings.
32 
33 @date 2012-04-19 Initial version.
34 */
36 {
37 public:
38 /*!
39 @brief Instantiates the object with default parameters (default constructor).
40 */
42  {
43  m_Buffer[0] = '\0';
44  }
45 
46 
47 /*!
48 @brief This is the copy constructor.
49 
50 @param[in] rhs Specifies the string to copy.
51 */
52  String(const String& rhs);
53 
54 
55 /*!
56 @brief Instantiates the object built from a C string.
57 
58 @param[in] pStr Specifies a pointer to a C string.
59 */
60  String(const char* pStr);
61 
62 
63 /*!
64 @brief Gets a pointer to the string buffer.
65 
66 @return Specifies a pointer to the string buffer.
67 */
68  const char* GetCharArray() const
69  {
70  return m_Buffer;
71  }
72 
73 
74 /*!
75 @brief This is an equality operator. It determines whether two <tt>String</tt> objects are equal.
76 
77 @param[in] rhs Specifies the string to compare.
78 
79 @return Returns <tt>true</tt> if the objects are equal, and <tt>false</tt> otherwise.
80 */
81  bool operator==(const String& rhs) const;
82 
83 
84 /*!
85 @brief This is an equality operator. It determines whether two <tt>String</tt> objects are not equal.
86 
87 @param[in] rhs Specifies the string to compare.
88 
89 @return Returns <tt>true</tt> if the objects are not equal, and <tt>false</tt> otherwise.
90 */
91  bool operator!=(const String& rhs) const
92  {
93  return !(*this == rhs);
94  }
95 
96 
97 /*!
98 @brief This is the assignment operator.
99 
100 @param[in] rhs Specifies the string to assign.
101 
102 @return Returns a reference to this instance.
103 */
104  String& operator=(const String& rhs);
105 
106 
107 /*!
108 @brief Builds a string according to the format.
109 
110 @param[in] pFormatString Specifies the format string.
111 @param[in] varg Specifies a variable argument list.
112 
113 @return Returns the length of the string after writing it.
114 */
115  s32 FormatV(const char* pFormatString, va_list varg);
116 
117 
118 /*!
119 @brief Builds a string according to the format.
120 
121 @param[in] pFormatString Specifies the format string.
122 @param[in] ... Specifies variable arguments.
123 
124 @return Returns the length of the string after writing it.
125 */
126  s32 Format(const char* pFormatString, ...);
127 
128 
129 /*!
130 @brief Calculates the length of a string.
131 
132 @return Specifies the length of the string.
133 */
134  u32 StrLen() const;
135 
136 
137 /*!
138 @brief Prints information useful for debugging.
139 
140 @param[in] flag Specifies the bitwise OR of trace flags. For more information, see the <tt>@ref TraceFlag</tt> type.
141 */
142  virtual void Trace(u64 flag) const;
143 
144 private:
145  enum
146  {
147  c_Length = 128
148  };
149 
150  char m_Buffer[c_Length];
151 };
152 }
153 }
154 } // end of namespace nn::pia::common
String()
Instantiates the object with default parameters (default constructor).
Definition: common_String.h:41
bool operator==(const String &rhs) const
This is an equality operator. It determines whether two String objects are equal. ...
const char * GetCharArray() const
Gets a pointer to the string buffer.
Definition: common_String.h:68
Definition: assert.h:115
Class for representing strings.
Definition: common_String.h:35
s32 FormatV(const char *pFormatString, va_list varg)
Builds a string according to the format.
bool operator!=(const String &rhs) const
This is an equality operator. It determines whether two String objects are not equal.
Definition: common_String.h:91
u32 StrLen() const
Calculates the length of a string.
String & operator=(const String &rhs)
This is the assignment operator.
virtual void Trace(u64 flag) const
Prints information useful for debugging.
s32 Format(const char *pFormatString,...)
Builds a string according to the format.
This is the common base class used inside the Pia library.
Definition: common_RootObject.h:40