source: sources/src/rpcResponse.cc @ 1464:3f6711617be1

Revision 1464:3f6711617be1, 3.1 KB checked in by niam, 22 months ago (diff)

{issue #58[resolved]} support for non-c++ exceptions

Line 
1/***************************************************************************
2 *            rpcResponse.cc
3 *
4 *  Sat Mar 22 2008
5 *  Copyright  2008  Dmytro Milinevskyy
6 *  milinevskyy@gmail.com
7 ****************************************************************************/
8
9/*
10 *  This program is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License version 2.1 as published by
12 *  the Free Software Foundation;
13 *
14 *  This program is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU Library General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public License
20 *  along with this program; if not, write to the Free Software
21 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24/**
25 * vim indentation settings
26 * set tabstop=4
27 * set shiftwidth=4
28 */
29
30#include <libdodo/directives.h>
31
32#include <libdodo/rpcResponse.h>
33
34#include <libdodo/types.h>
35#include <libdodo/rpcValue.h>
36#include <libdodo/rpcResponseEx.h>
37
38using namespace dodo::rpc;
39
40response::response() : succ(false)
41{
42}
43
44//-------------------------------------------------------------------
45
46response::~response()
47{
48}
49
50//-------------------------------------------------------------------
51
52value
53response::value(unsigned long position)
54{
55    if (position >= rValues.size())
56        dodo_throw exception::basic(exception::MODULE_RPCRESPONSE, RESPONSEEX_GETVALUE, exception::ERRNO_LIBDODO, RESPONSEEX_ARRAYOUTOFBOUNDS, RPCRESPONSEEX_ARRAYOUTOFBOUNDS_STR, __LINE__, __FILE__);
57
58    return rValues[position];
59}
60
61//-------------------------------------------------------------------
62
63bool
64response::isSuccessful()
65{
66    return succ;
67}
68
69//-------------------------------------------------------------------
70
71void
72response::addArgument(const dodo::rpc::value &argument)
73{
74    succ = true;
75
76    rValues.push_back(argument);
77}
78
79//-------------------------------------------------------------------
80
81void
82response::fault(const dodo::rpc::value &argument)
83{
84    succ = false;
85
86    rValues.assign(1, argument);
87}
88
89//-------------------------------------------------------------------
90
91dodo::rpc::value
92response::operator[](unsigned long position)
93{
94    if (position >= rValues.size())
95        dodo_throw exception::basic(exception::MODULE_RPCRESPONSE, RESPONSEEX_BROPERATORUNSIGNEDLONG, exception::ERRNO_LIBDODO, RESPONSEEX_ARRAYOUTOFBOUNDS, RPCRESPONSEEX_ARRAYOUTOFBOUNDS_STR, __LINE__, __FILE__);
96
97    return rValues[position];
98}
99
100//-------------------------------------------------------------------
101
102unsigned long
103response::valuesCount()
104{
105    return rValues.size();
106}
107
108//-------------------------------------------------------------------
109
110dodoArray<dodo::rpc::value>
111response::values()
112{
113    return rValues;
114}
115
116//-------------------------------------------------------------------
117
118void
119response::clear()
120{
121    rValues.clear();
122}
123
124//-------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.