VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tdbUtilities.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2003 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: utils.h,v $ $Revision: 1.1 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef tdbUtilities_H_
10 #define tdbUtilities_H_
11 
12 #include "tdbutil/tdbUtilDefines.h"
13 #include <stdio.h>
14 
15 /*
16  * Utility functions.
17  */
18 DT_DLL_tdbutil void ps(int indent_level);
19 
20 
21 /*
22  * These callback function types are defined so this library
23  * doesn't have to know about the GUI system but can still call
24  * GUI functions which update a ProgressMeterDialogBoxClass
25  */
26 typedef void MyProgressCallbackStartFunction(char *label, int range);
27 typedef void MyProgressCallbackSetValueFunction(int value);
29 typedef void MyProgressCallbackEndFunction(void);
30 
31 
32 /*
33  * The calling GUI code does this:
34  *
35  * static ProgressMeterDialogBoxClass* p = 0;
36  * static wxFrame* me = 0;
37  * void prog_start_fcn(char *label, int range) { p = new ProgressMeterDialogBoxClass(me, "label", range); }
38  * void prog_incremental_fcn(int increment) { p->DidSomeMore(increment); }
39  * void prog_set_value_fcn(int value) { p->SetValue(value); }
40  * void prog_end_fcn(void) { delete(p); }
41  *
42  *
43  * The called, time-intensive prototdb functions call these like:
44  *
45  * void load_db(MyProgressCallbackStartFunction *prog_start_fcnp,
46  * MyProgressCallbackSetValueFunction *prog_set_value_fcnp,
47  * MyProgressCallbackIncrementalProgressFunction *prog_incremental_fcnp,
48  * MyProgressCallbackEndFunction *prog_end_fcnp)
49  * {
50  * (*prog_start_fcnp)("Loading database", 10000);
51  *
52  * for (int i=0; i<10000; i++)
53  * {
54  * (*prog_set_value_fcnp)(i); // This, or...
55  * (*prog_incremental_fcnp)(1); // this.
56  * }
57  * (*prog_end_fcnp)();
58  * }
59  *
60  * Or, if you can live with the restrictions, inherit CanPopUpProgressMeter class.
61  */
62 
63 
64 
65 /****************************************************************
66  * File I/O
67  ****************************************************************/
68 DT_DLL_tdbutil size_t DtFileLength(const char *pathname);
69 
70 DT_DLL_tdbutil size_t DtFileLength(FILE *fp);
71 
72 DT_DLL_tdbutil FILE* DtFileOpenForReading(const char *pathname);
73 DT_DLL_tdbutil FILE* DtFileOpenForWriting(const char *pathname);
74 
75 // Closes the specified file pointer, but unlike DtFileClose(),
76 // this function will check that the file closed successfully, and
77 // print out warnings otherwise.
78 // @note This function will
79 // @returns True if the file closed successfully, false otherwise.
80 DT_DLL_tdbutil bool DtFileCloseVerbose(FILE *fp);
81 
82 DT_DLL_tdbutil size_t DtReadBytes(void *where, size_t size, FILE *fp);
83 
84 DT_DLL_tdbutil size_t DtReadMod4Bytes(void *where, size_t size, FILE *fp);
85 
86 // fgets with the newline (if any) stripped from the result
87 DT_DLL_tdbutil char* DtReadLine(char *buf, int bufSize, FILE *fp );
88 
89 //void DtSkipBytes(FILE *fp, size_t amount_to_skip);
90 
91 #endif
DT_DLL_tdbutil size_t DtFileLength(const char *pathname)
DT_DLL_tdbutil void ps(int indent_level)
void MyProgressCallbackStartFunction(char *label, int range)
Definition: tdbUtilities.h:26
DT_DLL_tdbutil size_t DtReadMod4Bytes(void *where, size_t size, FILE *fp)
voidpf void uLong size
Definition: ioapi.h:39
DT_DLL_tdbutil FILE * DtFileOpenForWriting(const char *pathname)
voidpf void * buf
Definition: ioapi.h:39
void MyProgressCallbackIncrementalProgressFunction(int increment)
Definition: tdbUtilities.h:28
DT_DLL_tdbutil FILE * DtFileOpenForReading(const char *pathname)
void MyProgressCallbackEndFunction(void)
Definition: tdbUtilities.h:29
DT_DLL_tdbutil bool DtFileCloseVerbose(FILE *fp)
#define DT_DLL_tdbutil
Definition: tdbUtilDefines.h:23
DT_DLL_tdbutil char * DtReadLine(char *buf, int bufSize, FILE *fp)
void MyProgressCallbackSetValueFunction(int value)
Definition: tdbUtilities.h:27
DT_DLL_tdbutil size_t DtReadBytes(void *where, size_t size, FILE *fp)

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)