libDwmCredence-0.1.32
DwmCredenceShortString.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2022, 2023
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
40//---------------------------------------------------------------------------
41
42#ifndef _DWMCREDENCESHORTSTRING_HH_
43#define _DWMCREDENCESHORTSTRING_HH_
44
45#include <string>
46
47namespace Dwm {
48
49 namespace Credence {
50
51 //------------------------------------------------------------------------
55 //------------------------------------------------------------------------
57 {
58 public:
59 //----------------------------------------------------------------------
61 //----------------------------------------------------------------------
62 ShortString() = default;
63
64 //----------------------------------------------------------------------
66 //----------------------------------------------------------------------
67 ShortString(const ShortString &) = default;
68
69 //----------------------------------------------------------------------
71 //----------------------------------------------------------------------
72 ShortString & operator = (const ShortString &) = default;
73
74 //----------------------------------------------------------------------
77 //----------------------------------------------------------------------
78 ShortString(const std::string & s);
79
80 //----------------------------------------------------------------------
83 //----------------------------------------------------------------------
84 ShortString & operator = (const std::string & s);
85
86 //----------------------------------------------------------------------
88 //----------------------------------------------------------------------
90
91 //----------------------------------------------------------------------
93 //----------------------------------------------------------------------
94 const std::string & Value() const;
95
96 //----------------------------------------------------------------------
98 //----------------------------------------------------------------------
99 operator std::string () const
100 { return _s; }
101
102 //----------------------------------------------------------------------
105 //----------------------------------------------------------------------
106 std::istream & Read(std::istream & is);
107
108 //----------------------------------------------------------------------
111 //----------------------------------------------------------------------
112 std::ostream & Write(std::ostream & os) const;
113
114 //----------------------------------------------------------------------
116 //----------------------------------------------------------------------
117 friend std::ostream & operator << (std::ostream & os,
118 const ShortString & shortString);
119
120 //----------------------------------------------------------------------
125 //----------------------------------------------------------------------
126 friend std::istream & operator >> (std::istream & is,
127 ShortString & shortString);
128
129 //----------------------------------------------------------------------
131 //----------------------------------------------------------------------
132 bool operator == (const ShortString & s) const;
133
134 //----------------------------------------------------------------------
136 //----------------------------------------------------------------------
137 void Clear();
138
139 private:
140 std::string _s;
141 };
142
143 } // namespace Credence
144
145} // namespace Dwm
146
147#endif // _DWMCREDENCESHORTSTRING_HH_
Encapsulates a string that is restricted to 255 bytes or less.
Definition DwmCredenceShortString.hh:57
const std::string & Value() const
Returns the contained string value.
ShortString(const ShortString &)=default
Copy constructor.
std::istream & Read(std::istream &is)
Reads the short string from the given istream is.
ShortString(const std::string &s)
Construct from the given string s.
friend std::ostream & operator<<(std::ostream &os, const ShortString &shortString)
ostream operator <<
friend std::istream & operator>>(std::istream &is, ShortString &shortString)
istream operator >>
ShortString & operator=(const ShortString &)=default
Assignment operator.
bool operator==(const ShortString &s) const
operator ==
ShortString()=default
Default constructor.
void Clear()
Clears the contents of the ShortString.
std::ostream & Write(std::ostream &os) const
Writes the shirt string to the given ostream os.