Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Platinum / Source / Core / PltArgument.cpp
blobbe358214a468793066a172e430ab5f67b089cc93
1 /*****************************************************************
3 | Platinum - Action Argument
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
33 ****************************************************************/
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #include "PltArgument.h"
39 #include "PltStateVariable.h"
40 #include "PltUtilities.h"
41 #include "PltAction.h"
43 NPT_SET_LOCAL_LOGGER("platinum.core.argument")
45 /*----------------------------------------------------------------------
46 | PLT_ArgumentDesc::PLT_ArgumentDesc
47 +---------------------------------------------------------------------*/
48 PLT_ArgumentDesc::PLT_ArgumentDesc(const char* name,
49 NPT_Ordinal position,
50 const char* direction,
51 PLT_StateVariable* variable,
52 bool has_ret) :
53 m_Name(name),
54 m_Position(position),
55 m_Direction(direction),
56 m_RelatedStateVariable(variable),
57 m_HasReturnValue(has_ret)
61 /*----------------------------------------------------------------------
62 | PLT_ArgumentDesc::GetSCPDXML
63 +---------------------------------------------------------------------*/
64 NPT_Result
65 PLT_ArgumentDesc::GetSCPDXML(NPT_XmlElementNode* node)
67 NPT_XmlElementNode* argument = new NPT_XmlElementNode("argument");
68 NPT_CHECK_SEVERE(node->AddChild(argument));
69 NPT_CHECK_SEVERE(PLT_XmlHelper::AddChildText(argument, "name", m_Name));
70 NPT_CHECK_SEVERE(PLT_XmlHelper::AddChildText(argument, "direction", m_Direction));
71 NPT_CHECK_SEVERE(PLT_XmlHelper::AddChildText(argument, "relatedStateVariable", m_RelatedStateVariable->GetName()));
73 if (m_HasReturnValue) {
74 NPT_CHECK_SEVERE(argument->AddChild(new NPT_XmlElementNode("retval")));
77 return NPT_SUCCESS;
80 /*----------------------------------------------------------------------
81 | PLT_Argument::CreateArgument
82 +---------------------------------------------------------------------*/
83 NPT_Result
84 PLT_Argument::CreateArgument(PLT_ActionDesc& action_desc,
85 const char* name,
86 const char* value,
87 PLT_Argument*& arg)
89 // reset output params first
90 arg = NULL;
92 PLT_ArgumentDesc* arg_desc = action_desc.GetArgumentDesc(name);
93 if (!arg_desc) {
94 NPT_LOG_WARNING_2("Invalid argument %s for action %s",
95 name,
96 (const char*)action_desc.GetName());
97 return NPT_ERROR_NO_SUCH_NAME;
100 NPT_Result res;
101 PLT_Argument* new_arg = new PLT_Argument(*arg_desc);
102 if (NPT_FAILED(res = new_arg->SetValue(value))) {
103 delete new_arg;
105 NPT_LOG_WARNING_3("Invalid value of %s for argument %s of action %s",
106 value,
107 name,
108 (const char*)action_desc.GetName());
109 return res;
112 arg = new_arg;
113 return NPT_SUCCESS;
116 /*----------------------------------------------------------------------
117 | PLT_Argument::PLT_Argument
118 +---------------------------------------------------------------------*/
119 PLT_Argument::PLT_Argument(PLT_ArgumentDesc& arg_desc) :
120 m_ArgDesc(arg_desc)
125 /*----------------------------------------------------------------------
126 | PLT_Argument::SetValue
127 +---------------------------------------------------------------------*/
128 NPT_Result
129 PLT_Argument::SetValue(const char* value)
131 NPT_CHECK_SEVERE(ValidateValue(value));
133 m_Value = value;
134 return NPT_SUCCESS;
137 /*----------------------------------------------------------------------
138 | PLT_Argument::GetValue
139 +---------------------------------------------------------------------*/
140 const NPT_String&
141 PLT_Argument::GetValue()
143 return m_Value;
146 /*----------------------------------------------------------------------
147 | PLT_Argument::ValidateValue
148 +---------------------------------------------------------------------*/
149 NPT_Result
150 PLT_Argument::ValidateValue(const char* value)
152 if (m_ArgDesc.GetRelatedStateVariable()) {
153 return m_ArgDesc.GetRelatedStateVariable()->ValidateValue(value);
155 return NPT_SUCCESS;