- Create the cache directly from the schema (installed) file.
[platform/upstream/libzypp.git] / zypp / TranslatedText.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/TranslatedText.h
10  *
11 */
12 #ifndef ZYPP_TRANSLATEDTEXT_H
13 #define ZYPP_TRANSLATEDTEXT_H
14
15 #include <iosfwd>
16 #include <map>
17 #include <list>
18 #include <set>
19 #include <string>
20
21 #include "zypp/base/PtrTypes.h"
22 #include "zypp/Locale.h"
23
24 ///////////////////////////////////////////////////////////////////
25 namespace zypp
26 { /////////////////////////////////////////////////////////////////
27
28   ///////////////////////////////////////////////////////////////////
29   //
30   //    CLASS NAME : TranslatedText
31   //
32   /** Class that represent a text and multiple translations.
33   */
34   class TranslatedText
35   {
36     friend std::ostream & operator<<( std::ostream & str, const TranslatedText & obj );
37
38   public:
39     /** Implementation  */
40     class Impl;
41
42   public:
43     /** Default ctor */
44     TranslatedText();
45     /** Ctor */
46     explicit
47     TranslatedText(const std::string &text, const Locale &lang = Locale());
48     /** Ctor. */
49     explicit
50     TranslatedText(const std::list<std::string> &text, const Locale &lang = Locale());
51     /** Dtor */
52     ~TranslatedText();
53
54     /** true if the text have no translations for any language */
55     bool empty() const ;
56     
57     /** static default empty translated text  */
58     static const TranslatedText notext;
59
60   public:
61
62     /** Synonym for \ref text */
63     std::string asString( const Locale &lang = Locale() ) const
64     { return text(lang); }
65
66     std::string text( const Locale &lang = Locale() ) const;
67     std::set<Locale> locales() const;
68
69     void setText( const std::string &text, const Locale &lang = Locale());
70     void setText( const std::list<std::string> &text, const Locale &lang = Locale());
71
72     Locale detectLanguage() const;
73
74   private:
75     /** Pointer to implementation */
76     RWCOW_pointer<Impl> _pimpl;
77   };
78   ///////////////////////////////////////////////////////////////////
79
80   /** \relates TranslatedText Stream output */
81   inline std::ostream & operator<<( std::ostream & str, const TranslatedText & obj )
82   { return str << obj.asString(); }
83
84   /////////////////////////////////////////////////////////////////
85 } // namespace zypp
86 ///////////////////////////////////////////////////////////////////
87 #endif // ZYPP_TRANSLATEDTEXT_H