Fix coding style according to tizen rule
[platform/core/security/drm-service-core-tizen.git] / tadcore / XMLParser / CXMLAttribute.cpp
1 /*
2  * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "CXMLAttribute.h"
18 #include "TADC_IF.h"
19 #include "TADC_ErrorCode.h"
20
21 //////////////////////////////////////////////////////////////////////
22 // Construction/Destruction
23 //////////////////////////////////////////////////////////////////////
24
25 CXMLAttribute::CXMLAttribute()
26         : m_pszName(NULL)
27         , m_pszValue(NULL)
28 {}
29
30 CXMLAttribute::~CXMLAttribute()
31 {
32         if (m_pszName)
33                 delete []m_pszName;
34
35         if (m_pszValue)
36                 delete []m_pszValue;
37 }
38
39 // [in] pszName : should be null-terminated string
40 int CXMLAttribute::SetName(LPCTSTR pszName)
41 {
42         int nResult = 0;
43         size_t pszNameLen = 0;
44
45         if (m_pszName) {
46                 delete []m_pszName;
47                 m_pszName = NULL;
48         }
49
50         pszNameLen = strlen(pszName);
51
52         m_pszName = new CHAR[pszNameLen + 1];
53         IF_TRUE_GOTO(m_pszName == NULL, ERROR_NOT_ENOUGH_MEMORY);
54
55         memcpy(m_pszName, pszName, pszNameLen + 1);
56
57 finish:
58
59         if (nResult)
60                 DRM_TAPPS_EXCEPTION("CXMLAttribute::SetName() Error!");
61
62         return nResult;
63 }
64
65 // [in] pszValue : should be null-terminated string
66 int CXMLAttribute::SetValue(LPCTSTR pszValue)
67 {
68         int nResult = 0;
69         size_t pszValueLen = 0;
70
71         if (m_pszValue) {
72                 delete []m_pszValue;
73                 m_pszValue = NULL;
74         }
75
76         pszValueLen = strlen(pszValue);
77
78         m_pszValue = new CHAR[pszValueLen + 1];
79         IF_TRUE_GOTO(m_pszName == NULL, ERROR_NOT_ENOUGH_MEMORY);
80
81         memcpy(m_pszValue, pszValue, pszValueLen + 1);
82
83 finish:
84
85         if (nResult)
86                 DRM_TAPPS_EXCEPTION("CXMLAttribute::SetValue() Error!");
87
88         return nResult;
89 }