MPQC  3.0.0-alpha
translate.h
1 
2 // translate.h -- data translation classes for StateIn and StateOut
3 //
4 // Copyright (C) 1997 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _util_state_translate_h
29 #define _util_state_translate_h
30 
31 #ifdef HAVE_CONFIG_H
32 #include <mpqc_config.h>
33 #endif
34 
35 #if defined(WORDS_BIGENDIAN)
36 #define BIGENDIAN 1
37 #else
38 #define BIGENDIAN 0
39 #endif
40 
41 namespace sc {
42 
46  public:
47  TranslateData();
48  virtual ~TranslateData();
49 
51  virtual char format_code();
52 
55  static TranslateData *vctor(char code);
56 
59  virtual void to_native (char *, int n);
62  virtual void to_external(char *, int n);
63  virtual void to_native (short *, int n);
64  virtual void to_external(short *, int n);
65  virtual void to_native (unsigned int *, int n);
66  virtual void to_external(unsigned int *, int n);
67  virtual void to_native (int *, int n);
68  virtual void to_external(int *, int n);
69  virtual void to_native (unsigned long *, int n);
70  virtual void to_external(unsigned long *, int n);
71  virtual void to_native (long *, int n);
72  virtual void to_external(long *, int n);
73  virtual void to_native (float *, int n);
74  virtual void to_external(float *, int n);
75  virtual void to_native (double *, int n);
76  virtual void to_external(double *, int n);
77 
80  virtual void to_native (char *target, const void *source, int n);
83  virtual void to_external(void *target, const char *source, int n);
84  virtual void to_native (short *, const void *, int n);
85  virtual void to_external(void *, const short *, int n);
86  virtual void to_native (unsigned int *, const void *, int n);
87  virtual void to_external(void *, const unsigned int *, int n);
88  virtual void to_native (int *, const void *, int n);
89  virtual void to_external(void *, const int *, int n);
90  virtual void to_native (unsigned long *, const void *, int n);
91  virtual void to_external(void *, const unsigned long *, int n);
92  virtual void to_native (long *, const void *, int n);
93  virtual void to_external(void *, const long *, int n);
94  virtual void to_native (float *, const void *, int n);
95  virtual void to_external(void *, const float *, int n);
96  virtual void to_native (double *, const void *, int n);
97  virtual void to_external(void *, const double *, int n);
98 };
99 
103  public:
105  virtual ~TranslateDataByteSwap();
106 
108  virtual char format_code();
109 
111  virtual void to_native (char *, int n);
113  virtual void to_external(char *, int n);
114  virtual void to_native (short *, int n);
115  virtual void to_external(short *, int n);
116  virtual void to_native (unsigned int *, int n);
117  virtual void to_external(unsigned int *, int n);
118  virtual void to_native (int *, int n);
119  virtual void to_external(int *, int n);
120  virtual void to_native (unsigned long *, int n);
121  virtual void to_external(unsigned long *, int n);
122  virtual void to_native (long *, int n);
123  virtual void to_external(long *, int n);
124  virtual void to_native (float *, int n);
125  virtual void to_external(float *, int n);
126  virtual void to_native (double *, int n);
127  virtual void to_external(double *, int n);
128 
130  virtual void to_native (char *, const void *, int n);
132  virtual void to_external(void *, const char *, int n);
133  virtual void to_native (short *, const void *, int n);
134  virtual void to_external(void *, const short *, int n);
135  virtual void to_native (unsigned int *, const void *, int n);
136  virtual void to_external(void *, const unsigned int *, int n);
137  virtual void to_native (int *, const void *, int n);
138  virtual void to_external(void *, const int *, int n);
139  virtual void to_native (unsigned long *, const void *, int n);
140  virtual void to_external(void *, const unsigned long *, int n);
141  virtual void to_native (long *, const void *, int n);
142  virtual void to_external(void *, const long *, int n);
143  virtual void to_native (float *, const void *, int n);
144  virtual void to_external(void *, const float *, int n);
145  virtual void to_native (double *, const void *, int n);
146  virtual void to_external(void *, const double *, int n);
147 };
148 
149 #if BIGENDIAN
152 #else
155 #endif
156 
157 class StateOut;
158 
163  private:
164  StateOut *so_;
165  TranslateData *translate_;
166  // the translation buffer
167  enum { bufsize = 8192 };
168  char buf_[bufsize];
169  protected:
170  int putv(const void*d,int s);
171  public:
175  virtual ~TranslateDataOut();
176 
179  virtual int put(const char*,int);
180  virtual int put(const short*,int);
181  virtual int put(const unsigned int*,int);
182  virtual int put(const int*,int);
183  virtual int put(const unsigned long*,int);
184  virtual int put(const long*,int);
185  virtual int put(const float*,int);
186  virtual int put(const double*,int);
187 
189  TranslateData *translator() { return translate_; }
190 };
191 
192 class StateIn;
193 
198  private:
199  StateIn *si_;
200  TranslateData *translate_;
201  protected:
202  int getv(void*d,int s);
203  public:
207  virtual ~TranslateDataIn();
208 
211  virtual int get(char*,int);
212  virtual int get(short*,int);
213  virtual int get(unsigned int*,int);
214  virtual int get(int*,int);
215  virtual int get(unsigned long*,int);
216  virtual int get(long*,int);
217  virtual int get(float*,int);
218  virtual int get(double*,int);
219 
221  TranslateData *translator() { return translate_; }
222 };
223 
224 }
225 
226 #endif
227 
228 // Local Variables:
229 // mode: c++
230 // c-file-style: "CLJ"
231 // End:
sc::TranslateDataByteSwap::to_native
virtual void to_native(char *, int n)
Overridden translation routines exist for all the basic types.
sc::TranslateDataIn::get
virtual int get(char *, int)
Read and translate data.
sc::TranslateData::to_native
virtual void to_native(char *, int n)
Translates to native format in-place.
sc::TranslateDataByteSwap::format_code
virtual char format_code()
Returns a code for the type of format for the external data.
sc::TranslateData::to_external
virtual void to_external(char *, int n)
Translates to external format in-place.
sc::TranslateData::format_code
virtual char format_code()
Returns a code for the type of format for the external data.
sc::TranslateDataByteSwap::to_external
virtual void to_external(char *, int n)
Overridden translation routines exist for all the basic types.
sc::TranslateData::vctor
static TranslateData * vctor(char code)
A virtual constructor that choses a specialization based on the format code.
sc::StateIn
Definition: statein.h:79
sc::TranslateDataOut::put
virtual int put(const char *, int)
Translate and write the data.
sc::TranslateDataIn::TranslateDataIn
TranslateDataIn(StateIn *s, TranslateData *t)
Input data will come from s.
sc::TranslateDataOut::TranslateDataOut
TranslateDataOut(StateOut *s, TranslateData *t)
Write to s using the translation defined by t.
sc::TranslateDataIn
Convert data from other formats.
Definition: translate.h:197
sc::TranslateDataOut::translator
TranslateData * translator()
Returns the translator.
Definition: translate.h:189
sc::TranslateDataOut
Convert data to other formats.
Definition: translate.h:162
sc::StateOut
Definition: stateout.h:71
sc::TranslateData
Generic data translation.
Definition: translate.h:45
sc::TranslateDataIn::translator
TranslateData * translator()
Return the translator.
Definition: translate.h:221
sc::TranslateDataByteSwap
Data translation to an external representation with bytes swapped.
Definition: translate.h:102
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:24:02 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.