bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
FFInt32.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// FreeForm sub-class implementation for FFByte,...FFGrid.
32// The files are patterned after the subcalssing examples
33// Test<type>.c,h files.
34//
35// ReZa 6/18/97
36
37#include "config_ff.h"
38
39static char rcsid[] not_used = {"$Id$"};
40
41
42#include "FFInt32.h"
43#include "util_ff.h"
44#include <libdap/util.h>
45
46#include <cstring>
47
48extern long BufPtr;
49extern char *BufVal;
50
51FFInt32::FFInt32(const string &n, const string &d) : Int32(n, d)
52{
53}
54
55BaseType *
56FFInt32::ptr_duplicate(){
57
58 return new FFInt32(*this);
59}
60
61bool
62FFInt32::read()
63{
64 if (read_p()) // nothing to do
65 return true;
66
67 if (BufVal) { // data in cache
68 char * ptr = BufVal+BufPtr;
69
70 // TODO Remove this and replace with set_value() if possible
71 // The same pattern is used in other classes here. jhrg 8/19/14
72 dods_int32 align;
73 if (width() > sizeof(align))
74 throw InternalErr(__FILE__, __LINE__, "Int32 size.");
75
76 memcpy((void*)&align, (void *)ptr, width());
77
78 val2buf((void *) &align);
79 set_read_p(true);
80
81 #ifdef TEST
82 dods_int32 *tmo;
83 tmo = (dods_int32 *)ptr;
84 printf("\n%ld offset=%ld\n",*tmo,BufPtr);
85 #endif
86
87 BufPtr += width();
88
89 return true;
90 }
91
92 return false;
93}
94