00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #include "buffer.h"
00036
00037 Buffer::Buffer(ProjectionDFA * _pdfa) {
00038 root = new BufferNode((TAG) TAGID_ROOT, NULL);
00039 cur = root;
00040
00041 ProjectionDFAState *is = _pdfa->getInitialState();
00042
00043 appendRoles(is->getCumulativeRoles(), is->getNonCumulativeRoles());
00044 }
00045
00046 Buffer::~Buffer() {
00047 delete root;
00048 }
00049
00050 void Buffer::appendTag(TAG tag) {
00051 BufferNode *t = new BufferNode(tag, cur);
00052
00053 cur->addChild(t);
00054 cur = t;
00055 }
00056
00057 void Buffer::appendTag(TAG tag, vector < unsigned >*_cumulative_roles,
00058 vector < unsigned >*_non_cumulative_roles) {
00059 BufferNode *t =
00060 new BufferNode(tag, cur, _cumulative_roles, _non_cumulative_roles);
00061 cur->addChild(t);
00062 cur = t;
00063 }
00064
00065 void Buffer::appendPCData(const char *data) {
00066 BufferNode *t = new BufferNode(data, cur);
00067
00068 cur->addChild(t);
00069 }
00070
00071 void Buffer::appendPCData(const char *data,
00072 vector < unsigned >*_cumulative_roles,
00073 vector < unsigned >*_non_cumulative_roles) {
00074 BufferNode *t =
00075 new BufferNode(data, cur, _cumulative_roles, _non_cumulative_roles);
00076 cur->addChild(t);
00077 }
00078
00079 void Buffer::appendRoles(vector < unsigned >*_cumulative_roles,
00080 vector < unsigned >*_non_cumulative_roles) {
00081 cur->appendRoles(_cumulative_roles, _non_cumulative_roles);
00082 }
00083
00084 void Buffer::print(OutputStream & dos) {
00085 root->print(dos);
00086 }
00087
00088 void Buffer::printCurrent(OutputStream & dos) {
00089 cur->print(dos);
00090 }
00091
00092 void Buffer::debugPrint(OutputStream & dos) {
00093 root->debugPrint(dos);
00094 }
00095
00096 void Buffer::closeTag() {
00097 cur->close();
00098 cur = cur->parent;
00099 }