53 enum class TraceLevels : uint8_t
60 void SetTraceLevel( TraceLevels tl );
126 int gdxAddAlias(
const char *Id1,
const char *Id2 );
171 int gdxAcronymAdd(
const char *AName,
const char *Txt,
int AIndx );
414 int gdxGetDomainElements(
int SyNr,
int DimPos,
int FilterNr, TDomainIndexProc_t DP,
int &NrElem,
void *Uptr );
485 int gdxOpenAppend(
const char *FileName,
const char *Producer,
int &ErrNr );
505 int gdxOpenRead(
const char *FileName,
int &ErrNr );
526 int gdxOpenReadEx(
const char *FileName,
int ReadMode,
int &ErrNr );
539 int gdxOpenWrite(
const char *FileName,
const char *Producer,
int &ErrNr );
569 int gdxOpenWriteEx(
const char *FileName,
const char *Producer,
int Compr,
int &ErrNr );
648 int gdxGetUEL(
int UelNr,
char *Uel )
const;
817 int gdxDataReadMap(
int RecNr,
int *KeyInt,
double *Values,
int &DimFrst );
963 int gdxDataReadSlice(
const char **UelFilterStr,
int &Dimen, TDataStoreProc_t DP );
993 int gdxDataReadStr(
char **KeyStr,
double *Values,
int &DimFrst );
1097 int gdxFileInfo(
int &FileVer,
int &ComprLev )
const;
1118 int gdxSymbolInfo(
int SyNr,
char *SyId,
int &Dimen,
int &Typ );
1183 int gdxSymbolInfoX(
int SyNr,
int &RecCnt,
int &UserInfo,
char *ExplTxt );
1365 int gdxUMFindUEL(
const char *Uel,
int &UelNr,
int &UelMap );
1376 int gdxUMUelGet(
int UelNr,
char *Uel,
int &UelMap );
1395 int gdxRenameUEL(
const char *OldName,
const char *NewName );
1513 int gdxDataWriteMapStart(
const char *SyId,
const char *ExplTxt,
int Dimen,
int Typ,
int UserInfo );
1595 int gdxDataWriteRawStart(
const char *SyId,
const char *ExplTxt,
int Dimen,
int Typ,
int UserInfo );
1668 int gdxDataWriteRawStartKeyBounds(
const char *SyId,
const char *ExplTxt,
int Dimen,
int Typ,
int UserInfo,
const int *MinUELIndices,
const int *MaxUELIndices );
1741 int gdxDataWriteStrStart(
const char *SyId,
const char *ExplTxt,
int Dimen,
int Typ,
int UserInfo );
1748std::unique_ptr<gdlib::gmsstrm::TMiBufferedStream> FFile;
1749TgxFileMode fmode { f_not_open }, fmode_AftReg { f_not_open };
1755} fstatus { stat_notopen };
1757std::unique_ptr<TUELTable> UELTable;
1758std::unique_ptr<TSetTextList> SetTextList {};
1759std::unique_ptr<int[]> MapSetText {};
1761std::array<int, GLOBAL_MAX_INDEX_DIM> LastElem {}, PrevElem {}, MinElem {}, MaxElem {};
1762std::array<std::array<char, GLOBAL_UEL_IDENT_SIZE>, GLOBAL_MAX_INDEX_DIM> LastStrElem {};
1764tvarvaltype LastDataField {};
1765std::unique_ptr<TNameList> NameList;
1766std::unique_ptr<TDomainStrList> DomainStrList;
1767std::unique_ptr<LinkedDataType> SortList;
1768std::optional<LinkedDataIteratorType> ReadPtr;
1769std::unique_ptr<TTblGamsDataImpl<double>> ErrorList;
1771int ErrCnt {}, ErrCntTotal {};
1772int LastError {}, LastRepError {};
1773std::unique_ptr<TFilterList> FilterList;
1775TDomainList DomainList {};
1776bool StoreDomainSets {
true }, AllowBogusDomain {
true }, MapAcrToNaN {};
1777TIntlValueMapDbl intlValueMapDbl {}, readIntlValueMapDbl {};
1778TIntlValueMapI64 intlValueMapI64 {};
1779TraceLevels TraceLevel { TraceLevels::trl_all };
1780std::string TraceStr;
1782std::string FProducer, FProducer2, FileSystemID;
1783int64_t MajorIndexPosition {};
1784int64_t NextWritePosition {};
1785int DataCount {}, NrMappedAdded {};
1786std::array<TgdxElemSize, GLOBAL_MAX_INDEX_DIM> ElemType {};
1787std::string MajContext;
1788std::array<TIntegerMapping, GLOBAL_MAX_INDEX_DIM> SliceIndxs {}, SliceRevMap {};
1790std::array<std::string, GMS_MAX_INDEX_DIM> SliceElems;
1791bool DoUncompress {},
1793int DeltaForWrite {};
1796std::unique_ptr<TAcronymList> AcronymList;
1797std::array<TSetBitMap *, GLOBAL_MAX_INDEX_DIM> WrBitMaps {};
1798bool ReadUniverse {};
1799int UniverseNr {}, UelCntOrig {};
1800int AutoConvert { 1 };
1801int NextAutoAcronym {};
1802bool AppendActive {};
1804#ifndef VERBOSE_TRACE
1805const TraceLevels defaultTraceLevel { TraceLevels::trl_none };
1806const bool verboseTrace {};
1808const TraceLevels defaultTraceLevel { TraceLevels::trl_all };
1809const bool verboseTrace {
true };
1813TDataStoreFiltProc_t gdxDataReadRawFastFilt_DP {};
1814TDomainIndexProc_t gdxGetDomainElements_DP {};
1816bool PrepareSymbolWrite( std::string_view Caller,
const char *AName,
const char *AText,
int ADim,
int AType,
int AUserInfo );
1817int PrepareSymbolRead( std::string_view Caller,
int SyNr,
const int *ADomainNrs, TgxFileMode newmode );
1820void SetError(
int N );
1821void ReportError(
int N );
1822bool ErrorCondition(
bool cnd,
int N );
1824bool MajorCheckMode( std::string_view Routine, TgxFileMode m );
1825bool MajorCheckMode( std::string_view Routine,
const TgxModeSet &MS );
1827bool CheckMode( std::string_view Routine );
1828bool CheckMode( std::string_view Routine, TgxFileMode m );
1829bool CheckMode( std::string_view Routine,
const TgxModeSet &MS );
1831void WriteTrace( std::string_view s )
const;
1832void InitDoWrite(
int NrRecs );
1833bool DoWrite(
const int *AElements,
const double *AVals );
1834bool DoRead(
double *AVals,
int &AFDim );
1835void AddToErrorListDomErrs(
const std::array<int, GLOBAL_MAX_INDEX_DIM> &AElements,
const double *AVals );
1836void AddToErrorList(
const int *AElements,
const double *AVals );
1837void GetDefaultRecord(
double *Avals )
const;
1838double AcronymRemap(
double V );
1839bool IsGoodNewSymbol(
const char *s );
1840bool ResultWillBeSorted(
const int *ADomainNrs )
const;
1842int gdxOpenReadXX(
const char *Afn,
int filemode,
int ReadMode,
int &ErrNr );
1845void gdxGetDomainElements_DP_FC(
int RawIndex,
int MappedIndex,
void *Uptr );
1846int gdxDataReadRawFastFilt_DP_FC(
const int *Indx,
const double *Vals,
void *Uptr );
1848void mapDefaultRecordValues(
double *AVals)
const;
1851bool gdxGetDomainElements_DP_CallByRef {},
1852 gdxDataReadRawFastFilt_DP_CallByRef {},
1853 gdxDataReadRawFastEx_DP_CallByRef {};
int gdxDataReadRawFastFilt(int SyNr, const char **UelFilterStr, TDataStoreFiltProc_t DP)
Read a symbol in Raw mode while applying a filter using a callback procedure. Returns zero if the ope...
Definition: gxfile.cpp:3596
static int gdxErrorStr(int ErrNr, char *ErrMsg)
Returns the text for a given error number. Always non-zero.
Definition: gxfile.cpp:1715
int gdxSymbolAddComment(int SyNr, const char *Txt)
Add a line of comment text for a symbol. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3511
int gdxAcronymGetInfo(int N, char *AName, char *Txt, int &AIndx) const
Retrieve acronym information from the acronym table. Non-zero if the index into the acronym table is ...
Definition: gxfile.cpp:2955
int gdxDataWriteRaw(const int *KeyInt, const double *Values)
Write a data element in raw mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2201
int gdxOpenReadEx(const char *FileName, int ReadMode, int &ErrNr)
Open a GDX file for reading allowing for skipping sections. Non-zero if the file can be opened,...
Definition: gxfile.cpp:2689
int gdxDataReadFilteredStart(int SyNr, const int *FilterAction, int &NrRecs)
Initialize the reading of a symbol in filtered mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3084
int gdxSymbolGetComment(int SyNr, int N, char *Txt)
Retrieve a line of comment text for a symbol. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3530
int gdxSetTraceLevel(int N, const char *s)
Set the amount of trace (debug) information generated. Always non-zero.
Definition: gxfile.cpp:3176
int gdxAddSetText(const char *Txt, int &TxtNr)
Register a string in the string table Register a string in the string table and return the integer nu...
Definition: gxfile.cpp:2121
int gdxUELRegisterStrStart()
Start registering unique elements in string mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2622
int gdxDataWriteStr(const char **KeyStr, const double *Values)
Write a data element in string mode. Each element string must follow the GAMS rules for unique elemen...
Definition: gxfile.cpp:472
int gdxUMUelInfo(int &UelCnt, int &HighMap) const
Return information about the unique elements (UELs). Always non-zero.
Definition: gxfile.cpp:2647
int gdxMapAcronymsToNaN() const
Flag to map all acronym values to the GAMS "Not a Number" special value. Disabled by default.
Definition: gxfile.cpp:3586
int gdxFilterRegisterStart(int FilterNr)
Define a unique element filter. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3032
int gdxUELRegisterMapStart()
Start registering unique elements in mapped mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2749
static int gdxGetDLLVersion(char *V)
Returns a version descriptor of the library. Always non-zero.
Definition: gxfile.cpp:3254
int64_t gdxGetMemoryUsed()
Return the number of bytes used by the data objects.
Definition: gxfile.cpp:3387
int gdxSymbolGetDomainX(int SyNr, char **DomainIDs)
Retrieve the domain of a symbol (using relaxed or domain information). Returns zero if the operation ...
Definition: gxfile.cpp:2366
int gdxSetTextNodeNr(int TxtNr, int Node)
Set the Node number for an entry in the string table. After registering a string with AddSetText,...
Definition: gxfile.cpp:3090
double gdxAcronymValue(int AIndx) const
Create an acronym value based on the index (AIndx should be greater than 0). Returns the calculated a...
Definition: gxfile.cpp:3242
int gdxDataReadRawFast(int SyNr, TDataStoreProc_t DP, int &NrRecs)
Read a symbol in Raw mode using a callback procedure. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3649
int gdxGetLastError()
Returns the last error number or zero if there was no error. Calling this function will clear the las...
Definition: gxfile.cpp:2262
int gdxDataWriteRawStart(const char *SyId, const char *ExplTxt, int Dimen, int Typ, int UserInfo)
Start writing a new symbol in raw mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2209
int gdxRenameUEL(const char *OldName, const char *NewName)
Rename unique element OldName to NewName.
Definition: gxfile.cpp:2667
int gdxDataErrorRecord(int RecNr, int *KeyInt, double *Values)
Retrieve an error record. Non-zero if the record number is valid.
Definition: gxfile.cpp:2140
int gdxSymbolSetDomain(const char **DomainIDs)
Define the domain of a symbol for which a write data operation just started using DataWriteRawStart,...
Definition: gxfile.cpp:2444
int gdxSymbolSetDomainX(int SyNr, const char **DomainIDs)
Define the domain of a symbol (relaxed version). Returns zero if the operation is not possible.
Definition: gxfile.cpp:2535
int gdxOpenWriteEx(const char *FileName, const char *Producer, int Compr, int &ErrNr)
Create a GDX file for writing with explicitly given compression flag. Non-zero if the file can be ope...
Definition: gxfile.cpp:397
int gdxUELRegisterRaw(const char *Uel)
Register unique element in raw mode. This can only be used while writing to a GDX file....
Definition: gxfile.cpp:2586
int gdxMapValue(double D, int &sv)
Classify a value as a potential special value. Non-zero if D is a special value, zero otherwise.
Definition: gxfile.cpp:3400
int gdxGetDomainElements(int SyNr, int DimPos, int FilterNr, TDomainIndexProc_t DP, int &NrElem, void *Uptr)
Get the unique elements for a given dimension of a given symbol.
Definition: gxfile.cpp:3102
int gdxOpenRead(const char *FileName, int &ErrNr)
Open a GDX file for reading. Non-zero if the file can be opened, zero otherwise.
Definition: gxfile.cpp:1722
int gdxStoreDomainSets() const
Get flag to store one dimensional sets as potential domains, false (0) saves lots of space for large ...
Definition: gxfile.cpp:3566
int gdxOpenAppend(const char *FileName, const char *Producer, int &ErrNr)
Open an existing GDX file for output. Non-zero if the file can be opened, zero otherwise.
Definition: gxfile.cpp:3420
void gdxStoreDomainSetsSet(int flag)
Set flag to store one dimensional sets as potential domains, false (0) saves lots of space for large ...
Definition: gxfile.cpp:3571
int gdxUELRegisterStr(const char *Uel, int &UelNr)
Register a unique element in string mode. A unique element must follow the GAMS rules when it contain...
Definition: gxfile.cpp:2610
int gdxDataWriteStrStart(const char *SyId, const char *ExplTxt, int Dimen, int Typ, int UserInfo)
Start writing a new symbol in string mode. Returns zero if the operation is not possible or failed.
Definition: gxfile.cpp:462
int gdxUELMaxLength() const
Returns the length of the longest unique element (UEL) name.
Definition: gxfile.cpp:3545
int gdxResetSpecialValues()
Reset the internal values for special values. Always non-zero.
Definition: gxfile.cpp:691
int gdxDataErrorRecordX(int RecNr, int *KeyInt, double *Values)
Retrieve an error record. Non-zero if the record number is valid.
Definition: gxfile.cpp:2153
int gdxAcronymName(double V, char *AName)
Find the name of an acronym value. Non-zero if a name for the acronym is defined. An unnamed acronym ...
Definition: gxfile.cpp:3228
int gdxSymbolDim(int SyNr)
Returns dimensionality of a symbol.
Definition: gxfile.cpp:2413
int gdxDataWriteMapStart(const char *SyId, const char *ExplTxt, int Dimen, int Typ, int UserInfo)
Start writing a new symbol in mapped mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2708
int gdxFileVersion(char *FileStr, char *ProduceStr) const
Return strings for file version and file producer. Always non-zero.
Definition: gxfile.cpp:1727
int gdxDataReadSliceStart(int SyNr, int *ElemCounts)
Prepare for the reading of a slice of data from a data set. The actual read of the data is done by ca...
Definition: gxfile.cpp:3279
int gdxAcronymNextNr(int NV)
Returns the value of the NextAutoAcronym variable and sets the variable to nv.
Definition: gxfile.cpp:3007
int gdxDataReadStr(char **KeyStr, double *Values, int &DimFrst)
Read the next record using strings for the unique elements. The reading should be initialized by call...
Definition: gxfile.cpp:1749
int gdxDataWriteDone()
Finish a write operation. Returns zero if the operation is not possible.
Definition: gxfile.cpp:508
int gdxDataReadRaw(int *KeyInt, double *Values, int &DimFrst)
Read the next record in raw mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2173
int gdxDataReadMapStart(int SyNr, int &NrRecs)
Initialize the reading of a symbol in mapped mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2774
int gdxDataSliceUELS(const int *SliceKeyInt, char **KeyStr)
Map a slice index in to the corresponding unique elements. After calling DataReadSliceStart,...
Definition: gxfile.cpp:3364
int gdxClose()
Close a GDX file that was previously opened for reading or writing. Before the file is closed,...
Definition: gxfile.cpp:533
int gdxDataReadRawStart(int SyNr, int &NrRecs)
Initialize the reading of a symbol in raw mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2194
int gdxDataWriteRawStartKeyBounds(const char *SyId, const char *ExplTxt, int Dimen, int Typ, int UserInfo, const int *MinUELIndices, const int *MaxUELIndices)
Start writing a new symbol in raw mode with bounds for UEL key indices being known in advance....
Definition: gxfile.cpp:2221
int gdxUMUelGet(int UelNr, char *Uel, int &UelMap)
Get a unique element using an unmapped index. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2631
int gdxAllowBogusDomains() const
Get flag to ignore using 1-dim sets as domain when their elements are not tracked (see gdxStoreDomain...
Definition: gxfile.cpp:3576
int gdxSymbolInfo(int SyNr, char *SyId, int &Dimen, int &Typ)
Returns information (name, dimension count, type) about a symbol from the symbol table....
Definition: gxfile.cpp:1816
int gdxUELRegisterMap(int UMap, const char *Uel)
Register unique element in mapped mode. A unique element must follow the GAMS rules when it contains ...
Definition: gxfile.cpp:2758
int gdxDataWriteMap(const int *KeyInt, const double *Values)
Write a data element in mapped mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2716
int gdxSystemInfo(int &SyCnt, int &UelCnt) const
Returns the number of symbols and unique elements. Always non-zero.
Definition: gxfile.cpp:2571
int gdxDataReadDone()
Finish reading of a symbol in any mode (raw, mapped, string). . Returns zero if the operation is not ...
Definition: gxfile.cpp:1778
int gdxFilterRegister(int UelMap)
Add a unique element to the current filter definition, zero if the index number is out of range or wa...
Definition: gxfile.cpp:3042
int gdxAcronymIndex(double V) const
Get index value of an acronym. Returns zero if V does not represent an acronym.
Definition: gxfile.cpp:3223
int gdxAcronymAdd(const char *AName, const char *Txt, int AIndx)
Add a new acronym entry. This can be used to add entries before data is written. Returns negative val...
Definition: gxfile.cpp:3204
int gdxDataReadSlice(const char **UelFilterStr, int &Dimen, TDataStoreProc_t DP)
Read a slice of data from a data set, by fixing zero or more index positions in the data....
Definition: gxfile.cpp:3320
int gdxSetSpecialValues(const double *AVals)
Set the internal values for special values. Before calling this function, initialize the array of spe...
Definition: gxfile.cpp:2303
int gdxDataErrorCount() const
Query the number of error records.
Definition: gxfile.cpp:2135
int gdxSymbMaxLength() const
Returns the length of the longest symbol name in the GDX file.
Definition: gxfile.cpp:3503
int gdxDataReadMap(int RecNr, int *KeyInt, double *Values, int &DimFrst)
Read the next record in mapped mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2781
int gdxFilterRegisterDone()
Finish registration of unique elements for a filter. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3059
int gdxUMFindUEL(const char *Uel, int &UelNr, int &UelMap)
Search for unique element by its string. Non-zero if the element was found, zero otherwise.
Definition: gxfile.cpp:3550
int gdxFilterExists(int FilterNr)
Check if there is a filter defined based on its number as used in gdxFilterRegisterStart....
Definition: gxfile.cpp:3026
int gdxDataReadRawFastEx(int SyNr, TDataStoreExProc_t DP, int &NrRecs, void *Uptr)
Read a symbol in Raw mode using a callback procedure. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3661
int gdxFindSymbol(const char *SyId, int &SyNr)
Search for a symbol by name in the symbol table; the search is not case-sensitive.
Definition: gxfile.cpp:1734
int gdxSetReadSpecialValues(const double *AVals)
Set the internal values for special values when reading a GDX file. Before calling this function,...
Definition: gxfile.cpp:3444
int gdxAddAlias(const char *Id1, const char *Id2)
Add an alias for a set to the symbol table. One of the two identifiers has to be a known set,...
Definition: gxfile.cpp:2081
int gdxGetSpecialValues(double *AVals)
Retrieve the internal values for special values. Always non-zero.
Definition: gxfile.cpp:2282
void gdxAllowBogusDomainsSet(int flag)
Set flag to ignore using 1-dim sets as domain when their elements are not tracked (see gdxStoreDomain...
Definition: gxfile.cpp:3581
~TGXFileObj()
Dispose GDX file object.
Definition: gxfile.cpp:682
int gdxGetUEL(int UelNr, char *Uel) const
Get the string for a unique element using a mapped index. Returns zero if the operation is not possib...
Definition: gxfile.cpp:2694
int gdxSymbolGetDomain(int SyNr, int *DomainSyNrs)
Retrieve the domain of a symbol. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2357
int gdxAcronymCount() const
Number of entries in the acronym table.
Definition: gxfile.cpp:2950
int gdxGetElemText(int TxtNr, char *Txt, int &Node)
Retrieve the string and node number for an entry in the string table. Returns zero if the operation i...
Definition: gxfile.cpp:2238
int gdxAcronymGetMapping(int N, int &orgIndx, int &newIndx, int &autoIndex)
Get information how acronym values are remapped. When reading GDX data, we need to map indices for ac...
Definition: gxfile.cpp:3014
int gdxCurrentDim() const
Returns the dimension of the currently active symbol When reading or writing data,...
Definition: gxfile.cpp:2662
int gdxSymbolInfoX(int SyNr, int &RecCnt, int &UserInfo, char *ExplTxt)
Returns additional information about a symbol. Returns zero if the symbol number is out of range,...
Definition: gxfile.cpp:2419
int gdxAutoConvert(int NV)
Returns the value of the AutoConvert variable and sets the variable to nv. When we close a new GDX fi...
Definition: gxfile.cpp:3247
int gdxSetHasText(int SyNr)
Test if any of the elements of the set has an associated text. Non-zero if the Set contains at least ...
Definition: gxfile.cpp:3439
int gdxErrorCount() const
Returns the number of errors.
Definition: gxfile.cpp:2233
int gdxOpenWrite(const char *FileName, const char *Producer, int &ErrNr)
Open a new GDX file for output. Non-zero if the file can be opened, zero otherwise.
Definition: gxfile.cpp:392
int gdxUELRegisterDone()
Finish registration of unique elements. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2578
int gdxFileInfo(int &FileVer, int &ComprLev) const
Returns file format number and compression level used. Always non-zero.
Definition: gxfile.cpp:3260
int gdxDataReadStrStart(int SyNr, int &NrRecs)
Initialize the reading of a symbol in string mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:1842
void gdxMapAcronymsToNaNSet(int flag)
Flag to map all acronym values to the GAMS "Not a Number" special value. Disabled by default.
Definition: gxfile.cpp:3591
int gdxUELRegisterRawStart()
Start registering unique elements in raw mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2602
int gdxSymbIndxMaxLength(int SyNr, int *LengthInfo)
Returns the length of the longest UEL used for every index position for a given symbol.
Definition: gxfile.cpp:3468
int gdxAcronymSetInfo(int N, const char *AName, const char *Txt, int AIndx)
Modify acronym information in the acronym table.
Definition: gxfile.cpp:2970