ZenLib
Translation.h
Go to the documentation of this file.
1 // ZenLib::Translation - Helper for translation
2 // Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 //
8 // Permission is granted to anyone to use this software for any purpose,
9 // including commercial applications, and to alter it and redistribute it
10 // freely, subject to the following restrictions:
11 //
12 // 1. The origin of this software must not be misrepresented; you must not
13 // claim that you wrote the original software. If you use this software
14 // in a product, an acknowledgment in the product documentation would be
15 // appreciated but is not required.
16 // 2. Altered source versions must be plainly marked as such, and must not be
17 // misrepresented as being the original software.
18 // 3. This notice may not be removed or altered from any source distribution.
19 //
20 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 //
22 //
23 //
24 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 
26 //---------------------------------------------------------------------------
27 #ifndef ZenLib_TranslationH
28 #define ZenLib_TranslationH
29 //---------------------------------------------------------------------------
30 
31 //---------------------------------------------------------------------------
32 #include "ZenLib/Ztring.h"
33 #include <map>
34 //---------------------------------------------------------------------------
35 
36 namespace ZenLib
37 {
38 
39 //***************************************************************************
40 /// @brief Helper for translation
41 //***************************************************************************
42 
43 class Translation : public std::map<Ztring, Ztring>
44 {
45 public :
46  //Constructors/Destructor
47  Translation ();
48  Translation (const Ztring &Source);
49  Translation (const Char *Source);
50  #ifdef _UNICODE
51  Translation (const char *Source); //convert a UTF-8 string into Unicode
52  #endif
53 
54  //In/Out
55  Ztring Get () const;
56  const Ztring &Get (const Ztring &Value);
57  Ztring Get (const Ztring &Count, const Ztring &Value);
58  void Write (const Ztring &NewLanguage); //All language in one
59  void Write (const Ztring &Value, const Ztring &NewLanguage); //Per item
60 
61  //Configuration
62  /// @brief Set the Separator character
63  void Separator_Set (size_type Level, const Ztring &NewSeparator);
64  /// @brief Set the Quote character
65  /// During Read() or Write() method, if Separator is in the sequence, we must quote it
66  void Quote_Set (const Ztring &NewQuote);
67  /// @brief Set the Maximum number of element to read
68  /// During Read() or Write() method, if there is more elements, merge them with the last element
69  void Max_Set (size_type Level, size_type Max);
70 
71 protected :
74  size_type Max[2];
75 };
76 
77 } //namespace
78 #endif
79