1
2 /* Web Polygraph http://www.web-polygraph.org/
3 * Copyright 2003-2011 The Measurement Factory
4 * Licensed under the Apache License, Version 2.0 */
5
6 #include "pgl/pgl.h"
7
8 #include "pgl/PglRec.h"
9 #include "pgl/PglSizeSym.h"
10 #include "pgl/PglNumSym.h"
11 #include "pgl/SingleRangeSym.h"
12
13
14
15 const String SingleRangeSym::TheType = "SingleRange";
16
17 static const String strFirstByteAbsolute = "first_byte_pos_absolute";
18 static const String strFirstByteRelative = "first_byte_pos_relative";
19 static const String strLastByteAbsolute = "last_byte_pos_absolute";
20 static const String strLastByteRelative = "last_byte_pos_relative";
21 static const String strSuffixLengthAbsolute = "suffix_length_absolute";
22 static const String strSuffixLengthRelative = "suffix_length_relative";
23
SingleRangeSym()24 SingleRangeSym::SingleRangeSym(): RangeSym(TheType, new PglRec) {
25 theRec->bAdd(SizeSym::TheType, strFirstByteAbsolute, 0);
26 theRec->bAdd(NumSym::TheType, strFirstByteRelative, 0);
27 theRec->bAdd(SizeSym::TheType, strLastByteAbsolute, 0);
28 theRec->bAdd(NumSym::TheType, strLastByteRelative, 0);
29 theRec->bAdd(SizeSym::TheType, strSuffixLengthAbsolute, 0);
30 theRec->bAdd(NumSym::TheType, strSuffixLengthRelative, 0);
31 }
32
SingleRangeSym(const String & aType,PglRec * aRec)33 SingleRangeSym::SingleRangeSym(const String &aType, PglRec *aRec): RangeSym(aType, aRec) {
34 }
35
isA(const String & type) const36 bool SingleRangeSym::isA(const String &type) const {
37 return RangeSym::isA(type) || type == TheType;
38 }
39
dupe(const String & type) const40 SynSym *SingleRangeSym::dupe(const String &type) const {
41 if (isA(type))
42 return new SingleRangeSym(this->type(), theRec->clone());
43 return RangeSym::dupe(type);
44 }
45
firstByteAbsolute(BigSize & sz) const46 bool SingleRangeSym::firstByteAbsolute(BigSize &sz) const {
47 return getSize(strFirstByteAbsolute, sz);
48 }
49
firstByteRelative(double & f) const50 bool SingleRangeSym::firstByteRelative(double &f) const {
51 return getDouble(strFirstByteRelative, f);
52 }
53
lastByteAbsolute(BigSize & sz) const54 bool SingleRangeSym::lastByteAbsolute(BigSize &sz) const {
55 return getSize(strLastByteAbsolute, sz);
56 }
57
lastByteRelative(double & f) const58 bool SingleRangeSym::lastByteRelative(double &f) const {
59 return getDouble(strLastByteRelative, f);
60 }
61
suffixLengthAbsolute(BigSize & sz) const62 bool SingleRangeSym::suffixLengthAbsolute(BigSize &sz) const {
63 return getSize(strSuffixLengthAbsolute, sz);
64 }
65
suffixLengthRelative(double & f) const66 bool SingleRangeSym::suffixLengthRelative(double &f) const {
67 return getDouble(strSuffixLengthRelative, f);
68 }
69