ircresponseparseresult.cpp
1 //------------------------------------------------------------------------------
2 // ircresponseparseresult.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2011 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "ircresponseparseresult.h"
24 
25 #include "irc/constants/ircresponsetype.h"
26 
27 // This is returned by IRCResponseParseResult::type() if the result is invalid.
28 // Do not modify contents of this var!
29 const IRCResponseType invalidResponseType;
30 
32 {
33  d.pResponseType = NULL;
34  d.bWasParsed = false;
35 }
36 
38 {
39  d.bWasParsed = bWasParsed;
40  d.pResponseType = new IRCResponseType(responseType);
41 }
42 
44 {
45  d.pResponseType = NULL;
46  copyIn(other);
47 }
48 
49 IRCResponseParseResult::~IRCResponseParseResult()
50 {
51  if (d.pResponseType != NULL)
52  {
53  delete d.pResponseType;
54  }
55 }
56 
57 void IRCResponseParseResult::copyIn(const IRCResponseParseResult& other)
58 {
59  d.bWasParsed = other.d.bWasParsed;
60  if (d.pResponseType != NULL)
61  {
62  delete d.pResponseType;
63  d.pResponseType = NULL;
64  }
65 
66  if (other.d.pResponseType != NULL)
67  {
68  d.pResponseType = new IRCResponseType(*other.d.pResponseType);
69  }
70 }
71 
72 IRCResponseParseResult& IRCResponseParseResult::operator=(const IRCResponseParseResult& other)
73 {
74  if (this != &other)
75  {
76  copyIn(other);
77  }
78 
79  return *this;
80 }
81 
83 {
84  if (d.pResponseType == NULL)
85  {
86  return invalidResponseType;
87  }
88 
89  return *d.pResponseType;
90 }
IRCResponseParseResult()
Creates an invalid object.
Defines types of IRC network response message.
const IRCResponseType & type() const
Type of the response as defined by IRCResponseType.
Result info generated by the IRCResponseParser.