1 /*****************************************************************************/ 2 // Copyright 2015-2019 Adobe Systems Incorporated 3 // All Rights Reserved. 4 // 5 // NOTICE: Adobe permits you to use, modify, and distribute this file in 6 // accordance with the terms of the Adobe license agreement accompanying it. 7 /*****************************************************************************/ 8 9 #ifndef __dng_local_string__ 10 #define __dng_local_string__ 11 12 /*****************************************************************************/ 13 14 #include "dng_classes.h" 15 #include "dng_string.h" 16 #include "dng_types.h" 17 18 #include <vector> 19 20 /*****************************************************************************/ 21 22 class dng_local_string 23 { 24 25 private: 26 27 dng_string fDefaultText; 28 29 struct dictionary_entry 30 { 31 32 dng_string fLanguage; 33 34 dng_string fTranslation; 35 dictionary_entrydictionary_entry36 dictionary_entry (const dng_string &language, 37 const dng_string &translation) 38 39 : fLanguage (language) 40 , fTranslation (translation) 41 42 { 43 44 } 45 46 }; 47 48 std::vector<dictionary_entry> fDictionary; 49 50 public: 51 52 dng_local_string (); 53 54 dng_local_string (const dng_string &s); 55 56 ~dng_local_string (); 57 58 void Clear (); 59 60 void SetDefaultText (const dng_string &s); 61 62 void AddTranslation (const dng_string &language, 63 const dng_string &translation); 64 65 void Set (const char *s); 66 DefaultText()67 const dng_string & DefaultText () const 68 { 69 return fDefaultText; 70 } 71 DefaultText()72 dng_string & DefaultText () 73 { 74 return fDefaultText; 75 } 76 TranslationCount()77 uint32 TranslationCount () const 78 { 79 return (uint32) fDictionary.size (); 80 } 81 Language(uint32 index)82 const dng_string & Language (uint32 index) const 83 { 84 return fDictionary [index] . fLanguage; 85 } 86 Translation(uint32 index)87 const dng_string & Translation (uint32 index) const 88 { 89 return fDictionary [index] . fTranslation; 90 } 91 92 const dng_string & LocalText (const dng_string &locale) const; 93 IsEmpty()94 bool IsEmpty () const 95 { 96 return DefaultText ().IsEmpty (); 97 } 98 NotEmpty()99 bool NotEmpty () const 100 { 101 return !IsEmpty (); 102 } 103 104 bool operator== (const dng_local_string &s) const; 105 106 bool operator!= (const dng_local_string &s) const 107 { 108 return !(*this == s); 109 } 110 111 void Truncate (uint32 maxBytes); 112 113 }; 114 115 /*****************************************************************************/ 116 117 #endif 118 119 /*****************************************************************************/ 120