COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
istreamFTN.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef _ISTREAMFTN_H_
9 #define _ISTREAMFTN_H_
10 
11 #include <covise/covise.h>
12 #include "istreamFTN.h"
13 #include "util/coTypes.h"
14 
15 #ifdef _WIN32
16 #include <io.h>
17 #include <fcntl.h>
18 #endif
19 
20 namespace covise
21 {
22 
24 {
25 
26 private:
29  int d_errFlag;
31 
32 public:
33  istreamFTN(int filedes)
34  : d_actBlockNo(1)
35  , d_fileDesc(filedes)
36  , d_errFlag(0)
37  , d_byteSwap(0){};
38 
40  {
41  close(d_fileDesc);
42  }
43 
44  int readFTN(void *data, int length);
45  int readFTN_BS(void *data, int length);
46 
47  int skipBlocks(int numBlocks);
48  int skipBlocks(int maxidx, int block)
49  {
50  if (maxidx > 0)
51  return skipBlocks((maxidx - 1) / block + 1);
52  else
53  return 1;
54  }
55 
56  int readFTNfloat(float *data, int num, int perBlock);
57  int readFTNint(int *data, int num, int perBlock);
58 
59  int getActualBlockNo() const
60  {
61  return d_actBlockNo;
62  }
63 
64  int fail()
65  {
66  return (d_errFlag != 0);
67  }
68 
70  int scanForSizeFloat(float *data, int num);
71  int scanForSizeInt(int *data, int num);
72 
74  int skipForSize(int size);
75 
77  void rewind();
78 
79  // switch Byteswapping on/off
80  void setByteSwap(int val)
81  {
82  d_byteSwap = (val != 0);
83  }
84 };
85 }
86 #endif
int getActualBlockNo() const
Definition: istreamFTN.h:59
#define STAREXPORT
Definition: coExport.h:188
int d_errFlag
Definition: istreamFTN.h:29
Definition: istreamFTN.h:23
istreamFTN(int filedes)
Definition: istreamFTN.h:33
int d_actBlockNo
Definition: istreamFTN.h:27
GLsizeiptr size
Definition: khronos-glext.h:6610
GLuint GLfloat * val
Definition: khronos-glext.h:7898
int fail()
Definition: istreamFTN.h:64
int skipBlocks(int maxidx, int block)
Definition: istreamFTN.h:48
void setByteSwap(int val)
Definition: istreamFTN.h:80
int d_fileDesc
Definition: istreamFTN.h:28
~istreamFTN()
Definition: istreamFTN.h:39
GLuint GLuint num
Definition: khronos-glext.h:10593
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
GLenum GLuint GLenum GLsizei length
Definition: khronos-glext.h:6279
int d_byteSwap
Definition: istreamFTN.h:30