31#include "datastorage.hpp"
40#include <initializer_list>
46namespace gdlib::gmsstrm
58 constexpr explicit operator int *()
noexcept {
return data(); }
59 constexpr explicit operator const int *()
const noexcept {
return data(); }
61class TgdxValues :
public std::array<double, GMS_VAL_SCALE + 1> {
63 constexpr explicit operator double*()
noexcept {
return data(); }
64 constexpr explicit operator const double *()
const noexcept {
return data(); }
67using TDomainIndexProc_t = void ( * )(
int RawIndex,
int MappedIndex,
void *Uptr );
68using TDataStoreProc_t = void ( * )(
const int *Indx,
const double *Vals );
69using TDataStoreFiltProc_t = int ( * )(
const int *Indx,
const double *Vals,
void *Uptr );
70using TDataStoreExProc_t = int ( * )(
const int *Indx,
const double *Vals,
const int afdim,
void *Uptr );
72using TDataStoreExProc_F = int ( * )(
const int *Indx,
const double *Vals,
const int afdim, int64_t Uptr );
73using TDataStoreFiltProc_F = int ( * )(
const int *Indx,
const double *Vals, int64_t Uptr );
74using TDomainIndexProc_F = void ( * )(
int RawIndex,
int MappedIndex, int64_t Uptr );
76const std::array<int, GMS_DT_ALIAS + 1> DataTypSize { 1, 1, 5, 5, 0 };
78constexpr int DOMC_UNMAPPED = -2,
82const std::string BADUEL_PREFIX =
"?L__",
83 BADStr_PREFIX =
"?Str__",
84 strGDXCOMPRESS =
"GDXCOMPRESS",
85 strGDXCONVERT =
"GDXCONVERT";
88 int FiltNumber {}, FiltMaxUel {};
89 gdlib::gmsobj::TBooleanBitArray FiltMap {};
92 TDFilter(
int Nr,
int UserHigh ) : FiltNumber { Nr },
93 FiltMaxUel { UserHigh }
99 [[nodiscard]]
int MemoryUsed()
const
101 return FiltMap.MemoryUsed();
104 [[nodiscard]]
bool InFilter(
int V )
const
106 return V >= 0 && V <= FiltMaxUel && FiltMap.GetBit( V );
109 void SetFilter(
int ix,
bool v )
111 FiltMap.SetBit( ix, v );
115using TSetBitMap = gdlib::gmsobj::TBooleanBitArray;
117enum class TgdxDAction : uint8_t
130using TDomainList = std::array<TDomain, GLOBAL_MAX_INDEX_DIM>;
132using TCommentsList = gdlib::gmsobj::TXStrings;
137 int SDim, SDataCount, SErrors;
141 utils::sstring SExplTxt;
144 std::unique_ptr<int[]> SDomSymbols,
146 std::optional<TCommentsList> SCommentsList;
147 std::unique_ptr<TSetBitMap> SSetBitMap;
151enum TgdxIntlValTyp : uint8_t
167enum TgxFileMode : uint8_t
190class TgxModeSet final :
public utils::IContainsPredicate<TgxFileMode>
192 std::array<bool, tgxfilemode_count> modeActive {};
196 TgxModeSet(
const std::initializer_list<TgxFileMode> &modes );
198 [[nodiscard]]
bool contains(
const TgxFileMode &mode )
const override;
199 [[nodiscard]]
bool empty()
const;
202const TgxModeSet AnyWriteMode { fw_init, fw_dom_raw, fw_dom_map, fw_dom_str, fw_raw_data, fw_map_data, fw_str_data },
203 AnyReadMode { fr_init, fr_raw_data, fr_map_data, fr_mapr_data, fr_str_data };
205enum class TgdxElemSize : uint8_t
218 int64_t FCapacity {}, FMapBytes {};
219 int64_t FMAXCAPACITY { std::numeric_limits<int>::max() +
static_cast<int64_t
>( 1 ) };
220 int FHighestIndex {};
223 void growMapping(
int F );
228 [[nodiscard]]
int MemoryUsed()
const;
229 [[nodiscard]]
int GetHighestIndex()
const;
230 [[nodiscard]]
int GetMapping(
int F )
const;
231 void SetMapping(
int F,
int T );
232 [[nodiscard]]
int size()
const;
233 [[nodiscard]]
bool empty()
const;
237enum class TUELUserMapStatus : uint8_t
247using TXStrHashListImpl = gdlib::strhash::TXStrHashList<T>;
250using TXCSStrHashListImpl = gdlib::strhash::TXCSStrHashList<T>;
254 TUELUserMapStatus FMapToUserStatus { TUELUserMapStatus::map_unknown };
257 std::unique_ptr<TIntegerMapping> UsrUel2Ent {};
260 [[nodiscard]]
int size()
const;
261 [[nodiscard]]
bool empty()
const;
262 [[nodiscard]]
int GetUserMap(
int i )
const;
263 void SetUserMap(
int EN,
int N );
264 int NewUsrUel(
int EN );
265 int AddUsrNew(
const char *s,
size_t slen );
266 int AddUsrIndxNew(
const char *s,
size_t slen,
int UelNr );
267 [[nodiscard]]
int GetMaxUELLength()
const;
268 int IndexOf(
const char *s );
269 int AddObject(
const char *
id,
size_t idlen,
int mapping );
270 int StoreObject(
const char *
id,
size_t idlen,
int mapping );
271 const char *operator[](
int index )
const;
272 void RenameEntry(
int N,
const char *s );
273 [[nodiscard]]
int MemoryUsed()
const;
274 void SaveToStream( gdlib::gmsstrm::TXStream &S );
275 void LoadFromStream( gdlib::gmsstrm::TXStream &S );
276 TUELUserMapStatus GetMapToUserStatus();
277 void ResetMapToUserStatus();
280int MakeGoodExplText(
char *s );
283 std::string AcrName, AcrText;
284 int AcrMap {}, AcrReadMap { -1 };
287 TAcronym(
const char *Name,
const char *Text,
int Map );
288 explicit TAcronym( gdlib::gmsstrm::TXStream &S );
291 [[nodiscard]]
int MemoryUsed()
const;
292 void SaveToStream( gdlib::gmsstrm::TXStream &S )
const;
293 void SetNameAndText(
const char *Name,
const char *Text );
298 bool useBatchAlloc {};
299 gdlib::gmsobj::TXList<TAcronym> FList;
300 gdlib::batchalloc::BatchAllocator<
sizeof(
TAcronym)> batchAlloc;
304 explicit TAcronymList(
bool _useBatchAlloc) : useBatchAlloc{_useBatchAlloc} {}
306 int FindEntry(
int Map );
307 int FindName(
const char *Name );
308 int AddEntry(
const char *Name,
const char *Text,
int Map );
309 void CheckEntry(
int Map );
310 void SaveToStream( gdlib::gmsstrm::TXStream &S );
311 void LoadFromStream( gdlib::gmsstrm::TXStream &S );
313 [[nodiscard]]
int size()
const;
319 gdlib::gmsobj::TXList<TDFilter> FList;
325 void DeleteFilter(
int ix );
327 [[nodiscard]]
size_t MemoryUsed()
const;
330using TIntlValueMapDbl = std::array<double, vm_count>;
331using TIntlValueMapI64 = std::array<int64_t, vm_count>;
333using LinkedDataType = gdlib::datastorage::TLinkedData<int, double>;
334using LinkedDataIteratorType = gdlib::datastorage::TLinkedDataRec<int, double> *;
336using TSetTextList = TXCSStrHashListImpl<int>;
338using TNameList = TXStrHashListImpl<PgdxSymbRecord>;
341using TTblGamsDataImpl = gdlib::gmsdata::TTblGamsData<T>;
343using TDomainStrList = TXStrHashListImpl<uint8_t>;
345enum tvarvaltype : uint8_t
354extern std::string DLLLoadPath;
362bool IsGoodIdent(
const char *S );
363bool CanBeQuoted(
const char *s,
size_t slen );
364bool GoodUELString(
const char *s,
size_t slen );
366int ConvertGDXFile(
const std::string &fn,
const std::string &MyComp );
Definition: gxfile.hpp:297
Definition: gxfile.hpp:318
Definition: gxfile.hpp:217
Definition: gxfile.hpp:253
Definition: gxfile.hpp:56
Definition: gxfile.hpp:61
Definition: gxfile.hpp:191
Definition: gxfile.hpp:282
Definition: gxfile.hpp:87
Definition: gxfile.hpp:125
Definition: gxfile.hpp:134
Definition: gxfile.hpp:357