bes  Updated for version 3.20.6
FFByte.cc
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of ff_handler a FreeForm API handler for the OPeNDAP
5 // DAP2 data server.
6 
7 // Copyright (c) 2005 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This is free software; you can redistribute it and/or modify it under the
11 // terms of the GNU Lesser General Public License as published by the Free
12 // Software Foundation; either version 2.1 of the License, or (at your
13 // option) any later version.
14 //
15 // This software is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 // License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1997-99
27 // Please read the full copyright statement in the file COPYRIGHT.
28 //
29 // Authors: reza (Reza Nekovei)
30 
31 
32 // FreeFrom sub-class implementation for FFByte,...FFGrid.
33 // The files are patterned after the subcalssing examples
34 // Test<type>.c,h files.
35 //
36 // ReZa 6/18/97
37 
38 #include "config_ff.h"
39 
40 static char rcsid[] not_used = {"$Id$"};
41 
42 
43 #include <string>
44 
45 #include "FFByte.h"
46 #include "util_ff.h"
47 #include "util.h"
48 
49 extern long BufPtr;
50 extern char * BufVal;
51 
52 // This `helper functions' creates a pointer to the a FFByte and returns
53 // that pointer. It takes the same arguments as the class's ctor. If any of
54 // the variable classes are subclassed (e.g., to make a new Byte like
55 // HDFByte) then the corresponding function here, and in the other class
56 // definition files, needs to be changed so that it creates an instance of
57 // the new (sub)class. Continuing the earlier example, that would mean that
58 // NewByte() would return a HDFByte, not a Byte.
59 //
60 // It is important that these function's names and return types do not change
61 // - they are called by the parser code (for the dds, at least) so if their
62 // names changes, that will break.
63 //
64 // The declarations for these functions (in util.h) should *not* need
65 // changing.
66 
67 FFByte::FFByte(const string &n, const string &d) : Byte(n, d)
68 {
69 }
70 
71 BaseType *
72 FFByte::ptr_duplicate()
73 {
74  return new FFByte(*this);
75 }
76 
77 bool FFByte::read()
78 {
79  if (read_p()) // nothing to do
80  return true;
81 
82  if (BufVal) { // Data in cache
83  char * ptr = BufVal + BufPtr;
84  val2buf((void *) ptr);
85  set_read_p(true);
86 
87  BufPtr += width();
88  return true;
89  }
90 
91  return false;
92 }
93 
94 // $Log: FFByte.cc,v $
95 // Revision 1.10 2003/02/10 23:01:52 jimg
96 // Merged with 3.2.5
97 //
98 // Revision 1.9.2.1 2002/12/18 23:30:42 pwest
99 // gcc3.2 compile corrections, mainly regarding the using statement
100 //
101 // Revision 1.9 2000/10/11 19:37:56 jimg
102 // Moved the CVS log entries to the end of files.
103 // Changed the definition of the read method to match the dap library.
104 // Added exception handling.
105 // Added exceptions to the read methods.
106 //
107 // Revision 1.8 1999/05/27 17:02:22 jimg
108 // Merge with alpha-3-0-0
109 //
110 // Revision 1.7.2.1 1999/05/20 21:39:27 edavis
111 // Fix spelling of COPYRIGHT and remove some #if 0 stuff.
112 //
113 // Revision 1.7 1999/05/04 02:55:36 jimg
114 // Merge with no-gnu
115 //
116 // Revision 1.6 1999/03/26 20:03:31 jimg
117 // Added support for the Int16, UInt16 and Float32 datatypes
118 //
119 // Revision 1.5.12.1 1999/05/01 04:40:29 brent
120 // converted old String.h to the new std C++ <string> code
121 //
122 // Revision 1.5 1998/08/13 20:24:21 jimg
123 // Fixed read mfunc semantics
124 //
125 // Revision 1.4 1998/08/12 21:20:51 jimg
126 // Massive changes from Reza. Compatible with the new FFND library
127 //
128 // Revision 1.3 1998/04/21 17:13:43 jimg
129 // Fixes for warnings, etc
130 //
131 // Revision 1.2 1998/04/16 18:11:00 jimg
132 // Sequence support added by Reza
FFByte
Definition: FFByte.h:51