1 /*****************************************************************************\
3 * Name : unhandled_request *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 2004-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "unhandled_request.h"
17 using namespace basis;
18 using namespace structures;
22 unhandled_request::unhandled_request(const octopus_request_id &original_id,
23 const string_array &original_classifier, const outcome &reason)
24 : infoton(the_classifier()),
25 _original_id(original_id),
26 _original_classifier(original_classifier),
30 clonable *unhandled_request::clone() const
31 { return new unhandled_request(_original_id, _original_classifier, _reason); }
33 int unhandled_request::packed_size() const
35 return _original_id.packed_size() + _original_classifier.packed_size()
36 + _reason.packed_size();
39 void unhandled_request::text_form(basis::base_string &fill) const
41 fill.assign(astring("classifier=") + the_classifier().text_form()
42 + " original_id=" + _original_id.text_form()
43 + a_sprintf(" reason=%d", _reason.value()));
46 const char *initter[] = { "__Unhandled__", NIL };
48 string_array unhandled_request::the_classifier()
49 { return string_array(1, initter); }
51 void unhandled_request::pack(byte_array &packed_form) const
53 _original_id.pack(packed_form);
54 _original_classifier.pack(packed_form);
55 attach(packed_form, _reason.value());
58 bool unhandled_request::unpack(byte_array &packed_form)
60 if (!_original_id.unpack(packed_form)) return false;
61 if (!_original_classifier.unpack(packed_form)) return false;
63 if (!detach(packed_form, val)) return false;
64 _reason = outcome(val);