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;
1749std::string lastFileName {};
1750TgxFileMode fmode { f_not_open }, fmode_AftReg { f_not_open };
1756} fstatus { stat_notopen };
1758std::unique_ptr<TUELTable> UELTable;
1759std::unique_ptr<TSetTextList> SetTextList {};
1760std::unique_ptr<int[]> MapSetText {};
1762std::array<int, GLOBAL_MAX_INDEX_DIM> LastElem {}, PrevElem {}, MinElem {}, MaxElem {};
1763std::array<std::array<char, GLOBAL_UEL_IDENT_SIZE>, GLOBAL_MAX_INDEX_DIM> LastStrElem {};
1765tvarvaltype LastDataField {};
1766std::unique_ptr<TNameList> NameList;
1767std::unique_ptr<TDomainStrList> DomainStrList;
1768std::unique_ptr<LinkedDataType> SortList;
1769std::optional<LinkedDataIteratorType> ReadPtr;
1770std::unique_ptr<TTblGamsDataImpl<double>> ErrorList;
1772int ErrCnt {}, ErrCntTotal {};
1773int LastError {}, LastRepError {};
1774std::unique_ptr<TFilterList> FilterList;
1776TDomainList DomainList {};
1777bool StoreDomainSets {
true }, AllowBogusDomain {
true }, MapAcrToNaN {};
1778TIntlValueMapDbl intlValueMapDbl {}, readIntlValueMapDbl {};
1779TIntlValueMapI64 intlValueMapI64 {};
1780TraceLevels TraceLevel { TraceLevels::trl_all };
1781std::string TraceStr;
1783std::string FProducer, FProducer2, FileSystemID;
1784int64_t MajorIndexPosition {};
1785int64_t NextWritePosition {};
1786int DataCount {}, NrMappedAdded {};
1787std::array<TgdxElemSize, GLOBAL_MAX_INDEX_DIM> ElemType {};
1788std::string MajContext;
1789std::array<TIntegerMapping, GLOBAL_MAX_INDEX_DIM> SliceIndxs {}, SliceRevMap {};
1791std::array<std::string, GMS_MAX_INDEX_DIM> SliceElems;
1792bool DoUncompress {},
1794int DeltaForWrite {};
1797std::unique_ptr<TAcronymList> AcronymList;
1798std::array<TSetBitMap *, GLOBAL_MAX_INDEX_DIM> WrBitMaps {};
1799bool ReadUniverse {};
1800int UniverseNr {}, UelCntOrig {};
1801int AutoConvert { 1 };
1802int NextAutoAcronym {};
1803bool AppendActive {};
1805#ifndef VERBOSE_TRACE
1806const TraceLevels defaultTraceLevel { TraceLevels::trl_none };
1807const bool verboseTrace {};
1809const TraceLevels defaultTraceLevel { TraceLevels::trl_all };
1810const bool verboseTrace {
true };
1814TDataStoreFiltProc_t gdxDataReadRawFastFilt_DP {};
1815TDomainIndexProc_t gdxGetDomainElements_DP {};
1817bool PrepareSymbolWrite( std::string_view Caller,
const char *AName,
const char *AText,
int ADim,
int AType,
int AUserInfo );
1818int PrepareSymbolRead( std::string_view Caller,
int SyNr,
const int *ADomainNrs, TgxFileMode newmode );
1821void SetError(
int N );
1822void ReportError(
int N );
1823bool ErrorCondition(
bool cnd,
int N );
1825bool MajorCheckMode( std::string_view Routine, TgxFileMode m );
1826bool MajorCheckMode( std::string_view Routine,
const TgxModeSet &MS );
1828bool CheckMode( std::string_view Routine );
1829bool CheckMode( std::string_view Routine, TgxFileMode m );
1830bool CheckMode( std::string_view Routine,
const TgxModeSet &MS );
1832void WriteTrace( std::string_view s )
const;
1833void InitDoWrite(
int NrRecs );
1834bool DoWrite(
const int *AElements,
const double *AVals );
1835bool DoRead(
double *AVals,
int &AFDim );
1836void AddToErrorListDomErrs(
const std::array<int, GLOBAL_MAX_INDEX_DIM> &AElements,
const double *AVals );
1837void AddToErrorList(
const int *AElements,
const double *AVals );
1838void GetDefaultRecord(
double *Avals )
const;
1839double AcronymRemap(
double V );
1840bool IsGoodNewSymbol(
const char *s );
1841bool ResultWillBeSorted(
const int *ADomainNrs )
const;
1843int gdxOpenReadXX(
const char *Afn,
int filemode,
int ReadMode,
int &ErrNr );
1846void gdxGetDomainElements_DP_FC(
int RawIndex,
int MappedIndex,
void *Uptr );
1847int gdxDataReadRawFastFilt_DP_FC(
const int *Indx,
const double *Vals,
void *Uptr );
1849void mapDefaultRecordValues(
double *AVals)
const;
1852bool gdxGetDomainElements_DP_CallByRef {},
1853 gdxDataReadRawFastFilt_DP_CallByRef {},
1854 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:3615
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:3529
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:2972
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:2221
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:2706
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:3101
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:3549
int gdxSetTraceLevel(int N, const char *s)
Set the amount of trace (debug) information generated. Always non-zero.
Definition: gxfile.cpp:3193
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:2141
int gdxUELRegisterStrStart()
Start registering unique elements in string mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2639
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:473
int gdxUMUelInfo(int &UelCnt, int &HighMap) const
Return information about the unique elements (UELs). Always non-zero.
Definition: gxfile.cpp:2664
int gdxMapAcronymsToNaN() const
Flag to map all acronym values to the GAMS "Not a Number" special value. Disabled by default.
Definition: gxfile.cpp:3605
int gdxFilterRegisterStart(int FilterNr)
Define a unique element filter. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3049
int gdxUELRegisterMapStart()
Start registering unique elements in mapped mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2766
static int gdxGetDLLVersion(char *V)
Returns a version descriptor of the library. Always non-zero.
Definition: gxfile.cpp:3271
int64_t gdxGetMemoryUsed()
Return the number of bytes used by the data objects.
Definition: gxfile.cpp:3404
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:2383
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:3107
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:3259
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:3668
int gdxGetLastError()
Returns the last error number or zero if there was no error. Calling this function will clear the las...
Definition: gxfile.cpp:2282
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:2229
int gdxRenameUEL(const char *OldName, const char *NewName)
Rename unique element OldName to NewName.
Definition: gxfile.cpp:2684
int gdxDataErrorRecord(int RecNr, int *KeyInt, double *Values)
Retrieve an error record. Non-zero if the record number is valid.
Definition: gxfile.cpp:2160
int gdxSymbolSetDomain(const char **DomainIDs)
Define the domain of a symbol for which a write data operation just started using DataWriteRawStart,...
Definition: gxfile.cpp:2461
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:2552
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:398
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:2603
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:3417
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:3119
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:1720
int gdxStoreDomainSets() const
Get flag to store one dimensional sets as potential domains, false (0) saves lots of space for large ...
Definition: gxfile.cpp:3585
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:3438
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:3590
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:2627
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:463
int gdxUELMaxLength() const
Returns the length of the longest unique element (UEL) name.
Definition: gxfile.cpp:3564
int gdxResetSpecialValues()
Reset the internal values for special values. Always non-zero.
Definition: gxfile.cpp:686
int gdxDataErrorRecordX(int RecNr, int *KeyInt, double *Values)
Retrieve an error record. Non-zero if the record number is valid.
Definition: gxfile.cpp:2173
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:3245
int gdxSymbolDim(int SyNr)
Returns dimensionality of a symbol.
Definition: gxfile.cpp:2430
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:2725
int gdxFileVersion(char *FileStr, char *ProduceStr) const
Return strings for file version and file producer. Always non-zero.
Definition: gxfile.cpp:1725
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:3296
int gdxAcronymNextNr(int NV)
Returns the value of the NextAutoAcronym variable and sets the variable to nv.
Definition: gxfile.cpp:3024
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:1747
int gdxDataWriteDone()
Finish a write operation. Returns zero if the operation is not possible.
Definition: gxfile.cpp:509
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:2193
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:2791
int gdxDataSliceUELS(const int *SliceKeyInt, char **KeyStr)
Map a slice index in to the corresponding unique elements. After calling DataReadSliceStart,...
Definition: gxfile.cpp:3381
int gdxClose()
Close a GDX file that was previously opened for reading or writing. Before the file is closed,...
Definition: gxfile.cpp:534
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:2214
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:2241
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:2648
int gdxAllowBogusDomains() const
Get flag to ignore using 1-dim sets as domain when their elements are not tracked (see gdxStoreDomain...
Definition: gxfile.cpp:3595
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:1814
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:2775
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:2733
int gdxSystemInfo(int &SyCnt, int &UelCnt) const
Returns the number of symbols and unique elements. Always non-zero.
Definition: gxfile.cpp:2588
int gdxDataReadDone()
Finish reading of a symbol in any mode (raw, mapped, string). . Returns zero if the operation is not ...
Definition: gxfile.cpp:1776
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:3059
int gdxAcronymIndex(double V) const
Get index value of an acronym. Returns zero if V does not represent an acronym.
Definition: gxfile.cpp:3240
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:3221
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:3337
int gdxSetSpecialValues(const double *AVals)
Set the internal values for special values. Before calling this function, initialize the array of spe...
Definition: gxfile.cpp:2320
int gdxDataErrorCount() const
Query the number of error records.
Definition: gxfile.cpp:2155
int gdxSymbMaxLength() const
Returns the length of the longest symbol name in the GDX file.
Definition: gxfile.cpp:3521
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:2798
int gdxFilterRegisterDone()
Finish registration of unique elements for a filter. Returns zero if the operation is not possible.
Definition: gxfile.cpp:3076
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:3569
int gdxFilterExists(int FilterNr)
Check if there is a filter defined based on its number as used in gdxFilterRegisterStart....
Definition: gxfile.cpp:3043
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:3680
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:1732
int gdxSetReadSpecialValues(const double *AVals)
Set the internal values for special values when reading a GDX file. Before calling this function,...
Definition: gxfile.cpp:3462
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:2101
int gdxGetSpecialValues(double *AVals)
Retrieve the internal values for special values. Always non-zero.
Definition: gxfile.cpp:2299
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:3600
~TGXFileObj()
Dispose GDX file object.
Definition: gxfile.cpp:677
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:2711
int gdxSymbolGetDomain(int SyNr, int *DomainSyNrs)
Retrieve the domain of a symbol. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2374
int gdxAcronymCount() const
Number of entries in the acronym table.
Definition: gxfile.cpp:2967
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:2258
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:3031
int gdxCurrentDim() const
Returns the dimension of the currently active symbol When reading or writing data,...
Definition: gxfile.cpp:2679
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:2436
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:3264
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:3457
int gdxErrorCount() const
Returns the number of errors.
Definition: gxfile.cpp:2253
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:393
int gdxUELRegisterDone()
Finish registration of unique elements. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2595
int gdxFileInfo(int &FileVer, int &ComprLev) const
Returns file format number and compression level used. Always non-zero.
Definition: gxfile.cpp:3277
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:1840
int gdxErrorStr(int ErrNr, char *ErrMsg) const
Returns the text for a given error number. Always non-zero.
Definition: gxfile.cpp:1710
void gdxMapAcronymsToNaNSet(int flag)
Flag to map all acronym values to the GAMS "Not a Number" special value. Disabled by default.
Definition: gxfile.cpp:3610
int gdxUELRegisterRawStart()
Start registering unique elements in raw mode. Returns zero if the operation is not possible.
Definition: gxfile.cpp:2619
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:3486
int gdxAcronymSetInfo(int N, const char *AName, const char *Txt, int AIndx)
Modify acronym information in the acronym table.
Definition: gxfile.cpp:2987
Definition: gxfile.hpp:191
Definition: gxfile.hpp:87
Definition: gxfile.hpp:134