~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to plugins/spit/qgsdbfbase.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Halasz
  • Date: 2004-12-21 09:46:27 UTC
  • Revision ID: james.westby@ubuntu.com-20041221094627-r9lb6mlz2o3yp8gn
Tags: upstream-0.6.0
ImportĀ upstreamĀ versionĀ 0.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    qgsbdfbase.h - Dbase IV Header
 
3
     --------------------------------------
 
4
    Date                 : 25-Dec-2003
 
5
    Copyright            : (C) 2003 by Gary E.Sherman
 
6
    email                : sherman at mrcc.com
 
7
 ***************************************************************************
 
8
 *                                                                         *
 
9
 *   This program is free software; you can redistribute it and/or modify  *
 
10
 *   it under the terms of the GNU General Public License as published by  *
 
11
 *   the Free Software Foundation; either version 2 of the License, or     *
 
12
 *   (at your option) any later version.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
 
15
/* $Id: qgsdbfbase.h,v 1.3 2004/02/14 16:44:16 gsherman Exp $ */
 
16
 
 
17
// Dbase header structure
 
18
 
 
19
struct DbaseHeader {
 
20
    unsigned char valid_dbf;
 
21
    char year;
 
22
    char month;
 
23
    char day;
 
24
    long num_recs;
 
25
    short size_hdr;
 
26
    short size_rec;
 
27
    char reserved[3];
 
28
    char lan[13];
 
29
    char reserved2[4];
 
30
};
 
31
// Field descriptor array - defines a field and its attributes (type,
 
32
// length, etc.
 
33
struct FieldDescriptorArray {
 
34
        char field_name[11];
 
35
        char field_type;
 
36
        long field_addr;  /* used only in memory */
 
37
        unsigned char field_length;
 
38
        unsigned char field_decimal;
 
39
        char reserved[2];
 
40
        char work_area;
 
41
        char lan[2];
 
42
        char set_fields;
 
43
        char reserved2[8];
 
44
};
 
45
// Typedefs
 
46
typedef struct FieldDescriptorArray Fda;
 
47
typedef struct DbaseHeader DbH;
 
48
 
 
49
// Field Array class
 
50
class DbaseFieldArray {
 
51
public:
 
52
        DbaseFieldArray(int numberOfFields);
 
53
        void addField(char *name, char type, unsigned char length,
 
54
                        unsigned char decimal);
 
55
        int getNumFields();
 
56
        Fda  *getField(int index);
 
57
private:
 
58
        struct FieldDescriptorArray *fda;
 
59
        unsigned int fieldCount;
 
60
        int numFields;
 
61
 
 
62
};
 
63
 
 
64
// Dbase file class (incomplete implementation)
 
65
class DbaseFile {
 
66
public:
 
67
    DbaseFile(char *fileName, int numRecords, int recordSize, DbaseFieldArray &fda);
 
68
        void writeHeader();
 
69
        void writeFieldDescriptors();
 
70
        void writeRecord(const char *data);
 
71
        void closeFile();
 
72
        struct DbaseHeader header;
 
73
private:
 
74
        char * fileName;
 
75
        int numRecords;
 
76
        int recordSize;
 
77
        DbaseFieldArray fieldArray;
 
78
        long pos;
 
79
        bool firstRecord;
 
80
};