bes  Updated for version 3.20.6
FFUInt32.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:
30 // ReZa Reza Nekovei (reza@intcomm.net)
31 
32 #include "config_ff.h"
33 
34 static char rcsid[] not_used = {"$Id$"};
35 
36 
37 #include "FFUInt32.h"
38 #include "util_ff.h"
39 #include "util.h"
40 
41 #include <cstring>
42 
43 extern long BufPtr;
44 extern char *BufVal;
45 
46 FFUInt32::FFUInt32(const string &n, const string &d) : UInt32(n, d)
47 {
48 }
49 
50 BaseType *
51 FFUInt32::ptr_duplicate(){
52 
53  return new FFUInt32(*this);
54 }
55 
56 bool
57 FFUInt32::read()
58 {
59  if (read_p()) // nothing to do
60  return true;
61 
62  // *** I don't know why no error is signaled when there's no data in
63  // BufVal. 10/11/2000 jhrg
64 
65  if(BufVal){ // data in cache
66  char * ptr = BufVal+BufPtr;
67 
68  dods_uint32 align;
69  if (width() > sizeof(align))
70  throw InternalErr(__FILE__, __LINE__, "UInt32 size.");
71 
72  memcpy((void*)&align, (void *)ptr, width());
73 
74  val2buf((void *) &align);
75  set_read_p(true);
76 
77  BufPtr += width();
78 
79  return true;
80  }
81 
82  return false;
83 }
FFUInt32
Definition: FFUInt32.h:45