📄 request.cpp
字号:
/******************************************************************************** request.cpp: User requests encapsulation*-------------------------------------------------------------------------------* (c)1999-2001 VideoLAN* $Id: request.cpp,v 1.1 2001/10/06 21:23:37 bozo Exp $** Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>** This program is free software; you can redistribute it and/or* modify it under the terms of the GNU General Public License* as published by the Free Software Foundation; either version 2* of the License, or (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.**-------------------------------------------------------------------------------********************************************************************************///------------------------------------------------------------------------------// Preamble//------------------------------------------------------------------------------#include "../core/defs.h"#include "config.h"#include "../core/core.h"#include "broadcast.h"#include "request.h"#define STRING_SEPARATOR ' '//******************************************************************************// class C_Request//******************************************************************************////******************************************************************************//------------------------------------------------------------------------------// Constructor.//------------------------------------------------------------------------------C_Request::C_Request(const C_String& strCmd) : m_strCmd(strCmd), m_cArgs(5){}//------------------------------------------------------------------------------// Set the value of an argument.//------------------------------------------------------------------------------void C_Request::SetArg(const C_String strArgName, const C_String& strArgValue){ ASSERT(strArgName != ""); C_String* pNewVal = new C_String(strArgValue); m_cArgs.Update(strArgName, pNewVal);}//------------------------------------------------------------------------------// Get the value of an argument.//------------------------------------------------------------------------------C_String C_Request::GetArg(const C_String& strArgName) const{ C_String* pArg = m_cArgs.Get(strArgName); if(pArg) return *pArg; else return C_String();}//------------------------------------------------------------------------------// Get the list of arguments.//------------------------------------------------------------------------------const C_HashTable<C_String, C_String>& C_Request::GetArgs() const{ return m_cArgs;}//******************************************************************************// class C_Answer//******************************************************************************////******************************************************************************//------------------------------------------------------------------------------// Constructor.//------------------------------------------------------------------------------C_Answer::C_Answer(const C_String& strProvider) : m_strProvider(strProvider){ m_iStatus = GEN_ERR;}//------------------------------------------------------------------------------// Get the name of the provider.//------------------------------------------------------------------------------const C_String& C_Answer::GetProvider() const{ return m_strProvider;}//------------------------------------------------------------------------------// Get th status.//------------------------------------------------------------------------------s32 C_Answer::GetStatus() const{ return m_iStatus;}//------------------------------------------------------------------------------// Get all the messages.//------------------------------------------------------------------------------const C_List<C_String>& C_Answer::GetMessages() const{ return m_cMessages;}//------------------------------------------------------------------------------// Get all the sub-answers.//------------------------------------------------------------------------------const C_List<C_Answer>& C_Answer::GetSubAnswers() const{ return m_cAnswerList;}//------------------------------------------------------------------------------// Set the status//------------------------------------------------------------------------------void C_Answer::SetStatus(s32 iStatus){ m_iStatus = iStatus;}//------------------------------------------------------------------------------// Add a message.//------------------------------------------------------------------------------void C_Answer::AddMessage(const C_String& strMessage){ m_cMessages.PushEnd(new C_String(strMessage));}//------------------------------------------------------------------------------// Add a sub-answer//------------------------------------------------------------------------------void C_Answer::Add(const C_Answer& cAnswer){ C_Answer* pAnswer = new C_Answer(cAnswer); ASSERT(pAnswer); m_cAnswerList.PushEnd(pAnswer);}//------------------------------------------------------------------------------// Clone the answer.//------------------------------------------------------------------------------C_Answer* C_Answer::Clone(){ C_Answer* pAnswer = new C_Answer(*this); ASSERT(pAnswer); return pAnswer;}//******************************************************************************// class C_Event//******************************************************************************////******************************************************************************//------------------------------------------------------------------------------// Constructor.//------------------------------------------------------------------------------C_Event::C_Event(const C_String& strProvider) : m_strProvider(strProvider){// m_iCode = NO_CODE;}//------------------------------------------------------------------------------// Get the provider of the event.//------------------------------------------------------------------------------const C_String& C_Event::GetProvider() const{ return m_strProvider;}//------------------------------------------------------------------------------// Get event's code//------------------------------------------------------------------------------s32 C_Event::GetCode() const{ return m_iCode;}//------------------------------------------------------------------------------// Get event's broadcast//------------------------------------------------------------------------------const C_Broadcast* C_Event::GetBroadcast() const{ return m_pBroadcast;}//------------------------------------------------------------------------------// Get the value of a property.//------------------------------------------------------------------------------/*C_String C_Event::GetProperty(const C_String& strPropName) const{ C_String* pProp = m_cProperties.Get(strPropName); if(pProp) return *pProp; else return C_String();}*///------------------------------------------------------------------------------// Get all the messages.//------------------------------------------------------------------------------const C_List<C_String>& C_Event::GetMessages() const{ return m_cMessages;}//------------------------------------------------------------------------------// Set event's code.//------------------------------------------------------------------------------void C_Event::SetCode(s32 iCode){ m_iCode = iCode;}//------------------------------------------------------------------------------// Set event's broadcast//------------------------------------------------------------------------------void C_Event::SetBroadcast(const C_Broadcast* pBroadcast){ m_pBroadcast = pBroadcast;}//------------------------------------------------------------------------------// Set the value of a property.//------------------------------------------------------------------------------/*void C_Event::SetProperty(const C_String strPropName, const C_String& strPropValue){ ASSERT(strPropName != ""); C_String* pNewVal = new C_String(strPropValue); m_cProperties.Update(strPropName, pNewVal);}*///------------------------------------------------------------------------------// Add a message.//------------------------------------------------------------------------------void C_Event::AddMessage(const C_String& strMessage){ m_cMessages.PushEnd(new C_String(strMessage));}//------------------------------------------------------------------------------// Clone.//------------------------------------------------------------------------------C_Event* C_Event::Clone(){ C_Event* pEvent = new C_Event(*this); ASSERT(pEvent); return pEvent;}//******************************************************************************// class C_Message//******************************************************************************////******************************************************************************//------------------------------------------------------------------------------// Constructor.//------------------------------------------------------------------------------C_Message::C_Message(const C_Request& cRequest) : m_cRequest(cRequest), m_cAnswer("none"), m_cEvent("none"){ m_iType = REQUEST_TYPE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -