11
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
12
// - special damages arising in any way out of the use of this software. -
13
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2012 amaury darsch -
14
// - copyright (c) 1999-2015 amaury darsch -
15
15
// ---------------------------------------------------------------------------
18
17
#include "Vector.hpp"
19
18
#include "AsnNode.hpp"
20
19
#include "AsnNode.hxx"
139
138
// -------------------------------------------------------------------------
139
// - public section -
140
// -------------------------------------------------------------------------
142
// the object eval quarks
143
static const long QUARK_ASNBER = String::intern ("BER");
144
static const long QUARK_ASNDER = String::intern ("DER");
145
static const long QUARK_ASNCER = String::intern ("CER");
146
static const long QUARK_ASNUNIV = String::intern ("UNIVERSAL");
147
static const long QUARK_ASNAPPL = String::intern ("APPLICATION");
148
static const long QUARK_ASNCTXS = String::intern ("CONTEXT-SPECIFIC");
149
static const long QUARK_ASNPRIV = String::intern ("PRIVATE");
150
static const long QUARK_ASNNODE = String::intern ("AsnNode");
152
// map an item to an encoding rule type
154
AsnNode::t_encr AsnNode::toencr (const Item& item) {
155
// check for an asn node item
156
if (item.gettid () != QUARK_ASNNODE)
157
throw Exception ("item-error", "item is not an asn node item");
158
// map the item to the enumeration
159
long quark = item.getquark ();
160
if (quark == QUARK_ASNBER) return AsnNode::ASN_BER;
161
if (quark == QUARK_ASNCER) return AsnNode::ASN_CER;
162
if (quark == QUARK_ASNDER) return AsnNode::ASN_DER;
163
throw Exception ("item-error", "cannot map item to asn encoding rule");
166
// map an item to a node class type
168
AsnNode::t_ncls AsnNode::toncls (const Item& item) {
169
// check for an asn node item
170
if (item.gettid () != QUARK_ASNNODE)
171
throw Exception ("item-error", "item is not an asn node item");
172
// map the item to the enumeration
173
long quark = item.getquark ();
174
if (quark == QUARK_ASNUNIV) return AsnNode::CLS_UNIV;
175
if (quark == QUARK_ASNAPPL) return AsnNode::CLS_APPL;
176
if (quark == QUARK_ASNCTXS) return AsnNode::CLS_CTXS;
177
if (quark == QUARK_ASNPRIV) return AsnNode::CLS_PRIV;
178
throw Exception ("item-error", "cannot map item to asn node class");
181
// -------------------------------------------------------------------------
140
182
// - protected section -
141
183
// -------------------------------------------------------------------------
495
537
// - object section -
496
538
// -------------------------------------------------------------------------
498
// the object eval quarks
499
static const long QUARK_ASNBER = String::intern ("BER");
500
static const long QUARK_ASNDER = String::intern ("DER");
501
static const long QUARK_ASNCER = String::intern ("CER");
502
static const long QUARK_ASNUNIV = String::intern ("UNIVERSAL");
503
static const long QUARK_ASNAPPL = String::intern ("APPLICATION");
504
static const long QUARK_ASNCTXS = String::intern ("CONTEXT-SPECIFIC");
505
static const long QUARK_ASNPRIV = String::intern ("PRIVATE");
506
static const long QUARK_ASNNODE = String::intern ("AsnNode");
508
540
// the quark zone
509
541
static const long QUARK_ZONE_LENGTH = 7;
510
542
static QuarkZone zone (QUARK_ZONE_LENGTH);