31#include "gdlib/datastorage.h"
33#include "gdlib/gmsdata.h"
34#include "gdlib/gmsobj.h"
35#include "gdlib/strhash.h"
36#include "gdlib/utils.h"
40#include <initializer_list>
46namespace gdlib::gmsstrm
56using TgdxUELIndex = std::array<int, GMS_MAX_INDEX_DIM>;
57using TgdxValues = std::array<double, GMS_VAL_SCALE + 1>;
59using TDomainIndexProc_t = void ( * )(
int RawIndex,
int MappedIndex,
void *Uptr );
60using TDataStoreProc_t = void ( * )(
const int *Indx,
const double *Vals );
61using TDataStoreFiltProc_t = int ( * )(
const int *Indx,
const double *Vals,
void *Uptr );
62using TDataStoreExProc_t = int ( * )(
const int *Indx,
const double *Vals,
const int afdim,
void *Uptr );
64using TDataStoreExProc_F = int ( * )(
const int *Indx,
const double *Vals,
const int afdim, int64_t Uptr );
65using TDataStoreFiltProc_F = int ( * )(
const int *Indx,
const double *Vals, int64_t Uptr );
66using TDomainIndexProc_F = void ( * )(
int RawIndex,
int MappedIndex, int64_t Uptr );
68const std::array<int, GMS_DT_ALIAS + 1> DataTypSize { 1, 1, 5, 5, 0 };
70constexpr int DOMC_UNMAPPED = -2,
74const std::string BADUEL_PREFIX =
"?L__",
75 BADStr_PREFIX =
"?Str__",
76 strGDXCOMPRESS =
"GDXCOMPRESS",
77 strGDXCONVERT =
"GDXCONVERT";
80 int FiltNumber {}, FiltMaxUel {};
81 gdlib::gmsobj::TBooleanBitArray FiltMap {};
84 TDFilter(
int Nr,
int UserHigh ) : FiltNumber { Nr },
85 FiltMaxUel { UserHigh }
91 [[nodiscard]]
int MemoryUsed()
const
93 return FiltMap.MemoryUsed();
96 [[nodiscard]]
bool InFilter(
int V )
const
98 return V >= 0 && V <= FiltMaxUel && FiltMap.GetBit( V );
101 void SetFilter(
int ix,
bool v )
103 FiltMap.SetBit( ix, v );
107using TSetBitMap = gdlib::gmsobj::TBooleanBitArray;
109enum class TgdxDAction : uint8_t
122using TDomainList = std::array<TDomain, GLOBAL_MAX_INDEX_DIM>;
124using TCommentsList = gdlib::gmsobj::TXStrings;
129 int SDim, SDataCount, SErrors;
133 std::array<char, GMS_SSSIZE> SExplTxt;
136 std::unique_ptr<int[]> SDomSymbols,
138 std::optional<TCommentsList> SCommentsList;
139 std::unique_ptr<TSetBitMap> SSetBitMap;
143enum TgdxIntlValTyp : uint8_t
159enum TgxFileMode : uint8_t
182class TgxModeSet :
public utils::IContainsPredicate<TgxFileMode>
184 std::array<bool, tgxfilemode_count> modeActive {};
188 TgxModeSet(
const std::initializer_list<TgxFileMode> &modes );
190 [[nodiscard]]
bool contains(
const TgxFileMode &mode )
const override;
191 [[nodiscard]]
bool empty()
const;
194const TgxModeSet AnyWriteMode { fw_init, fw_dom_raw, fw_dom_map, fw_dom_str, fw_raw_data, fw_map_data, fw_str_data },
195 AnyReadMode { fr_init, fr_raw_data, fr_map_data, fr_mapr_data, fr_str_data };
197enum class TgdxElemSize : uint8_t
210 int64_t FCapacity {}, FMapBytes {};
211 int64_t FMAXCAPACITY { std::numeric_limits<int>::max() +
static_cast<int64_t
>( 1 ) };
212 int FHighestIndex {};
215 void growMapping(
int F );
220 [[nodiscard]]
int MemoryUsed()
const;
221 [[nodiscard]]
int GetHighestIndex()
const;
222 [[nodiscard]]
int GetMapping(
int F )
const;
223 void SetMapping(
int F,
int T );
224 [[nodiscard]]
int size()
const;
225 [[nodiscard]]
bool empty()
const;
229enum class TUELUserMapStatus : uint8_t
239using TXStrHashListImpl = gdlib::strhash::TXStrHashList<T>;
242using TXCSStrHashListImpl = gdlib::strhash::TXCSStrHashList<T>;
246 TUELUserMapStatus FMapToUserStatus { TUELUserMapStatus::map_unknown };
249 std::unique_ptr<TIntegerMapping> UsrUel2Ent {};
252 [[nodiscard]]
int size()
const;
253 [[nodiscard]]
bool empty()
const;
254 [[nodiscard]]
int GetUserMap(
int i )
const;
255 void SetUserMap(
int EN,
int N );
256 int NewUsrUel(
int EN );
257 int AddUsrNew(
const char *s,
size_t slen );
258 int AddUsrIndxNew(
const char *s,
size_t slen,
int UelNr );
259 [[nodiscard]]
int GetMaxUELLength()
const;
260 int IndexOf(
const char *s );
261 int AddObject(
const char *
id,
size_t idlen,
int mapping );
262 int StoreObject(
const char *
id,
size_t idlen,
int mapping );
263 const char *operator[](
int index )
const;
264 void RenameEntry(
int N,
const char *s );
265 [[nodiscard]]
int MemoryUsed()
const;
266 void SaveToStream( gdlib::gmsstrm::TXStream &S );
267 void LoadFromStream( gdlib::gmsstrm::TXStream &S );
268 TUELUserMapStatus GetMapToUserStatus();
269 void ResetMapToUserStatus();
272int MakeGoodExplText(
char *s );
275 std::string AcrName, AcrText;
276 int AcrMap {}, AcrReadMap { -1 };
279 TAcronym(
const char *Name,
const char *Text,
int Map );
280 explicit TAcronym( gdlib::gmsstrm::TXStream &S );
283 [[nodiscard]]
int MemoryUsed()
const;
284 void SaveToStream( gdlib::gmsstrm::TXStream &S )
const;
285 void SetNameAndText(
const char *Name,
const char *Text );
290 gdlib::gmsobj::TXList<TAcronym> FList;
295 int FindEntry(
int Map );
296 int FindName(
const char *Name );
297 int AddEntry(
const char *Name,
const char *Text,
int Map );
298 void CheckEntry(
int Map );
299 void SaveToStream( gdlib::gmsstrm::TXStream &S );
300 void LoadFromStream( gdlib::gmsstrm::TXStream &S );
302 [[nodiscard]]
int size()
const;
308 gdlib::gmsobj::TXList<TDFilter> FList;
314 void DeleteFilter(
int ix );
316 [[nodiscard]]
size_t MemoryUsed()
const;
319using TIntlValueMapDbl = std::array<double, vm_count>;
320using TIntlValueMapI64 = std::array<int64_t, vm_count>;
322using LinkedDataType = gdlib::datastorage::TLinkedData<int, double>;
323using LinkedDataIteratorType = gdlib::datastorage::TLinkedDataRec<int, double> *;
325using TSetTextList = TXCSStrHashListImpl<int>;
327using TNameList = TXStrHashListImpl<PgdxSymbRecord>;
330using TTblGamsDataImpl = gdlib::gmsdata::TTblGamsData<T>;
332using TDomainStrList = TXStrHashListImpl<uint8_t>;
334enum tvarvaltype : uint8_t
343extern std::string DLLLoadPath;
351bool IsGoodIdent(
const char *S );
352bool CanBeQuoted(
const char *s,
size_t slen );
353bool GoodUELString(
const char *s,
size_t slen );
355int ConvertGDXFile(
const std::string &fn,
const std::string &MyComp );