-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVariable.h
More file actions
146 lines (129 loc) · 5.61 KB
/
Variable.h
File metadata and controls
146 lines (129 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Argus Open Source
* Software to apply Statistical Disclosure Control techniques
*
* Copyright 2014 Statistics Netherlands
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the European Union Public Licence
* (EUPL) version 1.1, as published by the European Commission.
*
* You can find the text of the EUPL v1.1 on
* https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
*
* This software is distributed on an "AS IS" basis without
* warranties or conditions of any kind, either express or implied.
*/
#if !defined Variable_h
#define Variable_h
#include <vector>
#include "General.h"
#include "defines.h"
#include "Code.h"
#include "SubCodeList.h"
typedef struct {
std::vector<std::string> sCode; // list of codes generated from recode, sorted upwards
int nCode; // number of codes, should be equal to sCode.GetSize()
std::string Missing1; // first missing value
std::string Missing2; // second missing value
int nMissing; // number of missing codes (usually 1 or 2)
int *DestCode; // m_var[SrcVar].nCode times an index to sCode
int CodeWidth; // max length sCodes
int nBogus;
CCode *hCode; // Properties hierarchical codes
} RECODE;
class CVariable
{
// Construction
public:
CVariable();
// Attributes
public:
long bPos; // starting position in record (first byte 0)
long nPos; // number of bytes
long nDec; // number of decimals
bool IsPeeper; //variable is Pieper
bool IsCategorical; // variable is categorical (sex, regio)
bool IsNumeric; // variable is counting item (income, number of persons)
bool IsWeight; // variable is weight
bool IsHierarchical; // variable is hierarchical
bool IsHolding; // variable is holding indicator
bool IsRecordKey; // variable is recordkey
int nMissing; // number of missing codes (usually 1 or 2)
std::string Missing1; // first missing value
std::string Missing2; // second missing value
std::string TotalCode; // code for Total
// computed during ExploreFile
double MinValue; // For numeric variables : minimum in data file
double MaxValue; // maximum in data file
std::vector<std::string> sCode; // For categorical variables: list of codes generated from microfile or from a file
std::vector<unsigned char> hLevel; // Levels hierarchical codelist, nCodes long
std::vector<unsigned char> hLevelBasic; // Basic code hierarchical codelist, nCodes long
int nCode; // number of codes, should be equal to sCode.GetSize()
// only relevant if IsHierarchical
int nDigitSplit; // number of digit groups (only if hierarchical)
int DigitSplit[MAXDIGITGROUP]; // Digit groups
CCode *hCode; // Properties hierarchical codes
long TableIndex; // used in FillTables
int ValueToggle; // used in FillTables
double Value; // used in FillTables
bool HasRecode; // toggle for Recode specification
bool HasCodeList; // toggle for Codelist specification form file
RECODE Recode; // recode specification, only relevant if HasRecode = true
std::string PeepCode1;
std::string PeepCode2;
bool PositionSet;
unsigned long NumSubCodes;
CSubCodeList *m_SubCodes;
// Operations
public:
// Implementation
public:
int nBogus;
int hfCodeWidth; // max width code hierarchical codelist from file
void UndoRecode();
CCode* GethCode();
bool SetHierarchicalRecode();
void PrintLevelStrings(FILE *fd, int nLevel, LPCTSTR LevelString);
void PrintLevelCode(FILE *fd, LPCTSTR code, LPCTSTR LevelString);
void WriteBogusCodelist(FILE *fd, LPCTSTR LevelString, int index, int level, int boguslevel, int ncode, std::vector<std::string> *CodeList);
bool WriteCodelist(LPCTSTR FileName, LPCTSTR LevelString, LPCTSTR Name, bool bogus);
bool SetHierarchicalDigits(long nDigitPairs, long *nDigits);
int FindHierarchicalCode(LPCTSTR code);
int FindAllHierarchicalCode(LPCTSTR code);
int SetCodeList(LPCTSTR FileName, LPCTSTR LevelString);
void SetActive(long CodeIndex, bool active);
bool SetHierarch();
//void GetGHMITERCode(int i, char* code);
void GetGHMITERCode(int i, std::string &code);
int GetCodeWidth();
bool IsCodeBasic(int i);
std::vector<std::string> * GetCodeList();
int GetnMissing();
std::string GetCode(int i);
int GetLevel(int i);
long GetDepthOfHerarchicalBoom(bool Recoded);
int GetnCode();
int GetnBogus();
int GetnCodeActive();
int GetnCodeInActive();
bool AddCode(const char *newcode, bool tail);
bool ComputeHierarchicalCodes();
bool SetMissing(LPCTSTR Missing1, LPCTSTR Missing2, long NumMissing);
bool SetTotalCode(LPCTSTR sTotalCode);
bool SetType(bool IsCategorical, bool IsNumeric, bool IsWeight, bool IsHierarchical, bool IsHolding, bool IsPeeper, bool bIsRecordKey);
bool SetPeepCodes(const std::string &Peep1, const std::string &Peep2);
bool SetPosition(long bPos, long nPos, long nDec);
bool SetDecPosition(long lnDec);
virtual ~CVariable();
long OrganizeCodelist();
long NumberOfSubCodeList();
bool PrepareSubCodeList();
bool CreateSubCodeForHierarchicalCode(long CodeIndex, long SubCodeSequenceNumber);
bool CreateSubCodeForNonHierarchicalCode();
bool FillSubCodeList();
long FindNumberOfChildren(long CodeIndex);
bool FindChildren(long NumChild, std::vector<std::string> &Child, long CodeIndex, long *Index);
bool NormaliseCode(char *Code);
};
#endif // Variable_h