CLI  2.9
resource_string.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006-2018, Alexis Royer, http://alexis.royer.free.fr/CLI
3 
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of the CLI library project nor the names of its contributors may be used to endorse or promote products derived from this software
12  without specific prior written permission.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 
31 
32 #ifndef _CLI_STRING_H_
33 #define _CLI_STRING_H_
34 
35 #include "cli/namespace.h"
36 #include "cli/object.h"
37 #include "cli/tk.h"
38 
39 
41 
42 
43  class ResourceString : public Object
46  {
47  public:
49  explicit ResourceString(void);
50 
53  const ResourceString& CLI_String
54  );
55 
57  virtual ~ResourceString(void);
58 
59  public:
63  const ResourceString& STR_String
64  );
65 
66  public:
68  typedef enum
69  {
73  LANG_DEFAULT = LANG_EN
74  } LANG;
75 
76  public:
80  ResourceString& Reset(void);
81 
88  const LANG E_Lang,
89  const char* const STR_String
90  );
91 
95  const bool HasString(
96  const LANG E_Lang
97  ) const;
98 
103  const tk::String GetString(
104  const LANG E_Lang
105  ) const;
106 
110  const bool IsEmpty(void) const;
111 
112  public:
115  static const tk::String Concat(
116  const char* const STR_1,
117  const char* const STR_2
118  );
119 
122  static const tk::String Concat(
123  const char* const STR_1,
124  const char* const STR_2,
125  const char* const STR_3
126  );
127 
130  static const tk::String Concat(
131  const char* const STR_1,
132  const char* const STR_2,
133  const char* const STR_3,
134  const char* const STR_4
135  );
136 
139  static const tk::String Concat(
140  const char* const STR_1,
141  const char* const STR_2,
142  const char* const STR_3,
143  const char* const STR_4,
144  const char* const STR_5
145  );
146 
147  private:
149  typedef tk::Map<const LANG, tk::String> LangStringMap;
151  LangStringMap m_mapStrings;
152  };
153 
159  const ResourceString& CLI_Str1,
160  const ResourceString& CLI_Str2
161  );
162 
164 
165 #endif // _CLI_STRING_H_
166 
Generic object.
Definition: object.h:42
Main namespace of the CLI library.
const tk::String GetString(const LANG E_Lang) const
Access to the string of a given language.
virtual ~ResourceString(void)
Destructor.
ResourceString(void)
Default constructor.
const ResourceString operator+(const ResourceString &CLI_Str1, const ResourceString &CLI_Str2)
Addition operator.
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
LANG
Languages identifiers.
ResourceString class.
const bool HasString(const LANG E_Lang) const
Determines whether a string exists for a given language.
ResourceString & Reset(void)
Resets the resource string.
Namespace management.
ResourceString & operator=(const ResourceString &STR_String)
Assignment operator.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
CLI toolkit definition.
Object class definition.
ResourceString & SetString(const LANG E_Lang, const char *const STR_String)
Adds resource for a given language.
static const tk::String Concat(const char *const STR_1, const char *const STR_2)
String concatenation in the aim of a resource definition.
const bool IsEmpty(void) const
Determines whether the resource string is empty (ie no string has been set for any language)...