3
Copyright (c) 2006-2007, BBR Inc. All rights reserved.
5
Permission is hereby granted, free of charge, to any person obtaining
6
a copy of this software and associated documentation files (the
7
"Software"), to deal in the Software without restriction, including
8
without limitation the rights to use, copy, modify, merge, publish,
9
distribute, sublicense, and/or sell copies of the Software, and to
10
permit persons to whom the Software is furnished to do so, subject to
11
the following conditions:
13
The above copyright notice and this permission notice shall be included
14
in all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
#include "P2POutputStream.h"
35
#include "P2POutput.h"
41
/* find object with original object number and generation */
42
static P2PObject *find(int orgNumA, int orgGenA);
54
P2PObject(int orgNumA, int orgGenA) {
65
virtual ~P2PObject() {
67
P2PXRef::remove(this);
69
void setOffset(int offsetA) {
72
void setOffset(P2POutputStream *str) {
73
offset = str->getPosition();
75
int getOffset() { return offset; }
77
void setNum(int numA, int genA) {
82
void getNum(int *numA, int *genA) {
87
/* output begin object */
88
void outputBegin(P2POutputStream *str);
89
/* output end object */
90
void outputEnd(P2POutputStream *str);
91
/* output reference */
92
void outputRef(P2POutputStream *str);
94
/* output as an object */
95
virtual void output(P2POutputStream *str, XRef *xref) {
96
error(-1,const_cast<char *>("Illegal output call of P2PObject:%d"),num);
99
GBool isSecondPhase() { return secondPhase; }
100
void setSecondPhase(GBool v) { secondPhase = v; }
103
/* original object number hash table */
104
static P2PObject **orgTable;
106
static int hash(int num, int gen);
108
/* put this into original object number table */
110
/* remove this from original object number able */
113
/* original object number */
115
/* original object generation */
120
/* object generation */
122
/* offset in output file */
123
/* when minus value, not output this yet. */
125
/* next object pointer for list */
127
/* flag indicating that should be output in second phase */
131
class P2PObj : public P2PObject {
134
P2PObj(Object *objA) {
142
virtual void output(P2POutputStream *str, XRef *xref) {
143
if (getOffset() < 0) {
147
if (num > 0) outputBegin(str);
148
P2POutput::outputObject(&obj,str,xref);
150
if (num > 0) outputEnd(str);
153
void setObj(Object *objA) {