source: trunk/gsdl/src/mgpp/text/text.cpp@ 879

Last change on this file since 879 was 855, checked in by sjboddie, 24 years ago

Rodgers new C++ mg

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/**************************************************************************
2 *
3 * text.h -- Header file for compression related stuff
4 * Copyright (C) 1999 Rodger McNab
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: text.cpp 855 2000-01-14 02:17:52Z sjboddie $
21 *
22 **************************************************************************/
23
24#include "text.h"
25
26// UCArray currently contains all the basic reading and writing
27// functions
28#include "UCArray.h"
29
30
31compressed_text_header::compressed_text_header () {
32 Clear();
33}
34
35void compressed_text_header::Clear () {
36 num_of_docs = 0;
37 num_of_words = 0;
38 num_of_bytes = 0.0;
39}
40
41
42bool compressed_text_header::Read (FILE *f) {
43 return (ReadUL (f, num_of_docs) &&
44 ReadUL (f, num_of_words) &&
45 ReadD (f, num_of_bytes));
46}
47
48bool compressed_text_header::Write (FILE *f) const {
49 return (WriteUL (f, num_of_docs) &&
50 WriteUL (f, num_of_words) &&
51 WriteD (f, num_of_bytes));
52}
53
54
55auxiliary_dict::auxiliary_dict () {
56 word_data[0] = NULL;
57 word_data[1] = NULL;
58 words[0] = NULL;
59 words[1] = NULL;
60}
61
62auxiliary_dict::~auxiliary_dict () {
63 Clear ();
64}
65
66void auxiliary_dict::Clear () {
67 if (word_data[0] != NULL) {
68 delete word_data[0];
69 word_data[0] = NULL;
70 }
71 if (word_data[1] != NULL) {
72 delete word_data[1];
73 word_data[1] = NULL;
74 }
75 if (words[0] != NULL) {
76 delete words[0];
77 words[0] = NULL;
78 }
79 if (words[1] != NULL) {
80 delete words[1];
81 words[1] = NULL;
82 }
83}
84
85
86compression_dict::compression_dict () {
87 int which;
88 for (which = 0; which < 2; which++) {
89 cfh[which] = NULL;
90 values[which] = NULL;
91 escape[which] = NULL;
92 chars_huff[which] = NULL;
93 chars_vals[which] = NULL;
94 lens_huff[which] = NULL;
95 lens_vals[which] = NULL;
96 }
97
98 MemForCompDict = 0;
99 ad = NULL;
100 fast_loaded = 0;
101}
102
103compression_dict::~compression_dict () {
104 Clear ();
105}
106
107void compression_dict::Clear () {
108 int which;
109 for (which = 0; which < 2; which++) {
110 if (cfh[which] != NULL) {
111 delete cfh[which];
112 cfh[which] = NULL;
113 }
114 if (values[which] != NULL) {
115 delete values[which][0][0];
116 delete values[which][0];
117 delete values[which];
118 values[which] = NULL;
119 }
120 if (escape[which] != NULL) { // don't know if needed
121 delete escape[which];
122 escape[which] = NULL;
123 }
124 if (chars_huff[which] != NULL) {
125 delete chars_huff[which];
126 chars_huff[which] = NULL;
127 }
128 if (chars_vals[which] != NULL) {
129 delete chars_vals[which][0];
130 delete chars_vals[which];
131 chars_vals[which] = NULL;
132 }
133 if (lens_huff[which] != NULL) {
134 delete lens_huff[which];
135 lens_huff[which] = NULL;
136 }
137 if (lens_vals[which] != NULL) {
138 delete lens_vals[which][0];
139 delete lens_vals[which];
140 lens_vals[which] = NULL;
141 }
142 }
143
144 if (ad != NULL) {
145 delete ad;
146 ad = NULL;
147 }
148
149 MemForCompDict = 0;
150 fast_loaded = 0;
151}
Note: See TracBrowser for help on using the repository browser.