sync with tizen_2.0
[platform/framework/native/appfw.git] / src / app / FApp_AppResourceString.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FApp_AppResourceString.h
20  * @brief       This is the header file of the _AppResourceString class.
21  */
22
23 #ifndef _FAPP_INTERNAL_APP_RESOURCE_STRING_H_
24 #define _FAPP_INTERNAL_APP_RESOURCE_STRING_H_
25
26 #include <FBaseObject.h>
27 #include <FBaseString.h>
28
29 namespace Tizen { namespace Locales { class Locale; } }
30
31 struct _xmlDoc;
32 typedef _xmlDoc* xmlDocPtr;
33
34 namespace Tizen { namespace App
35 {
36
37 class _AppResourceString
38         : public Tizen::Base::Object
39 {
40 public:
41         /**
42         * This is the destructor for this class.
43         *
44         * @since                1.0
45         */
46         virtual ~_AppResourceString(void);
47
48         /**
49         * Gets the string at the specified resource ID.
50         *
51         * @since                1.0
52         * @return               An error code
53         * @param[in]    resourceId              The resource ID describing the String resource
54         * @param[out]   loadedString    The string obtained from the loaded application resource
55         * @exception    E_SUCCESS                                 The method was successful.
56         * @exception    E_FAILURE                       The argument passed is not found.
57         * @exception    E_INVALID_STATE   The state of XML context is not in a valid state.
58         * @exception    E_INVALID_ARG                   The argument passed to a method contains an invalid resource ID.
59         */
60         result GetString(const Tizen::Base::String resourceId, Tizen::Base::String& loadedString);
61
62         /**
63         * Initializes this instance.
64         *
65         */
66         result Construct(void);
67
68         /**
69         * Initializes this instance with the specified locale.
70         *
71         */
72         result Construct(const Tizen::Locales::Locale& locale);
73
74
75         result Initialize(void);
76
77         result Construct(const AppId& appId);
78
79         result Initialize(const AppId& appId);
80
81 private:
82         result InitializeStringInfo(void);
83         result InitializeStringInfo(const AppId& appId);
84         static bool HasSpecialString(const Tizen::Base::String& resourceStr);
85         static result ConvertToCstyleString(const Tizen::Base::String& resourceStr, Tizen::Base::String& convertedStr);
86         static xmlDocPtr ParseXmlFile(const Tizen::Base::String& path);
87
88 private:
89         /**
90         * This is the default constructor for this class.
91         *
92         * @since        1.0
93         */
94         _AppResourceString(void);
95
96         /**
97         * This is the copy constructor for this class.
98         *
99         * @since        1.0
100         */
101         _AppResourceString(const _AppResourceString& source);
102
103         /**
104          * This is the assignment operator for this class.
105          */
106         _AppResourceString& operator =(const _AppResourceString& source);
107
108 private:
109
110         xmlDocPtr __pDoc;
111         Tizen::Base::Runtime::Mutex* __pLockOfParser;
112
113         friend class _AppResourceImpl;
114 }; // _AppResourceString
115
116 } } // Tizen::App
117
118 #endif // _FAPP_INTERNAL_APP_RESOURCE_STRING_H_