Pol  Revision:3cfda13
datastore.cpp
Go to the documentation of this file.
1 
11 #include "datastore.h"
12 
13 #include <exception>
14 #include <fstream>
15 #include <stddef.h>
16 
17 #include "../../bscript/berror.h"
18 #include "../../bscript/bobject.h"
19 #include "../../bscript/bstruct.h"
20 #include "../../bscript/executor.h"
21 #include "../../bscript/impstr.h"
22 #include "../../bscript/objmethods.h"
23 #include "../../clib/cfgelem.h"
24 #include "../../clib/cfgfile.h"
25 #include "../../clib/fileutil.h"
26 #include "../../clib/rawtypes.h"
27 #include "../../clib/streamsaver.h"
28 #include "../../plib/pkg.h"
29 #include "../../plib/systemstate.h"
30 #include "../globals/ucfg.h"
31 #include "../proplist.h"
32 #include "datastoreimp.h"
33 
34 namespace Pol
35 {
36 namespace Bscript
37 {
38 using namespace Module;
39 template <>
42  {"ListDataFiles", &DataFileExecutorModule::mf_ListDataFiles},
43  {"CreateDataFile", &DataFileExecutorModule::mf_CreateDataFile},
44  {"OpenDataFile", &DataFileExecutorModule::mf_OpenDataFile},
45  {"UnloadDataFile", &DataFileExecutorModule::mf_UnloadDataFile}};
46 }
47 
48 namespace Module
49 {
57 
60 
61 DataFileContents::DataFileContents( DataStoreFile* dsf ) : dsf( dsf ), dirty( false ) {}
62 
64 {
65  elements_by_integer.clear();
66  elements_by_string.clear();
67 }
68 
70 {
71  size_t size = sizeof( DataStoreFile* ) /*dsf*/
72  + sizeof( bool ); /*dirty*/
73 
74  for ( const auto& ele : elements_by_string )
75  {
76  size += ele.first.capacity() + sizeof( DataFileElementRef ) + ( sizeof( void* ) * 3 + 1 ) / 2;
77  if ( ele.second.get() != nullptr )
78  size += ele.second->proplist.estimatedSize();
79  }
80  size += ( sizeof( int ) + sizeof( DataFileElementRef ) + ( sizeof( void* ) * 3 + 1 ) / 2 ) *
81  elements_by_integer.size();
82  return size;
83 }
84 
86 {
87  Clib::ConfigElem elem;
88 
89  while ( cf.read( elem ) )
90  {
91  DataFileElement* delem = new DataFileElement( elem );
92 
93  if ( dsf->flags & DF_KEYTYPE_INTEGER )
94  {
95  elements_by_integer[atol( elem.rest() )].set( delem );
96  }
97  else
98  {
99  elements_by_string[elem.rest()].set( delem );
100  }
101  }
102 }
103 
105 {
106  for ( const auto& element : elements_by_string )
107  {
108  sw() << "Element " << element.first << "\n"
109  << "{\n";
110  element.second->printOn( sw );
111  sw() << "}\n\n";
112  // sw.flush();
113  }
114 
115  for ( const auto& element : elements_by_integer )
116  {
117  sw() << "Element " << element.first << "\n"
118  << "{\n";
119  element.second->printOn( sw );
120  sw() << "}\n\n";
121  // sw.flush();
122  }
123 }
124 
126 {
127  ElementsByInteger::iterator itr = elements_by_integer.find( key );
128  DataFileElementRef dfelem;
129  if ( itr == elements_by_integer.end() )
130  {
131  dfelem.set( new DataFileElement );
132  elements_by_integer[key] = dfelem;
133  dirty = true;
134  }
135  else
136  {
137  dfelem = ( *itr ).second;
138  }
139  return new DataElemRefObjImp( DataFileContentsRef( this ), dfelem );
140 }
141 
143 {
144  ElementsByString::iterator itr = elements_by_string.find( key );
145  DataFileElementRef dfelem;
146  if ( itr == elements_by_string.end() )
147  {
148  dfelem.set( new DataFileElement );
149  elements_by_string[key] = dfelem;
150  dirty = true;
151  }
152  else
153  {
154  dfelem = ( *itr ).second;
155  }
156  return new DataElemRefObjImp( DataFileContentsRef( this ), dfelem );
157 }
158 
159 
161 {
162  ElementsByInteger::iterator itr = elements_by_integer.find( key );
163  if ( itr != elements_by_integer.end() )
164  {
165  DataFileElementRef dfelem = ( *itr ).second;
166  return new DataElemRefObjImp( DataFileContentsRef( this ), dfelem );
167  }
168  else
169  {
170  return new Bscript::BError( "Element not found" );
171  }
172 }
173 
175 {
176  ElementsByString::iterator itr = elements_by_string.find( key );
177  if ( itr != elements_by_string.end() )
178  {
179  DataFileElementRef dfelem = ( *itr ).second;
180  return new DataElemRefObjImp( DataFileContentsRef( this ), dfelem );
181  }
182  else
183  {
184  return new Bscript::BError( "Element not found" );
185  }
186 }
187 
188 
190 {
191  if ( elements_by_integer.erase( key ) )
192  {
193  dirty = true;
194  return new Bscript::BLong( 1 );
195  }
196  else
197  return new Bscript::BError( "Element not found" );
198 }
199 
201 {
202  if ( elements_by_string.erase( key ) )
203  {
204  dirty = true;
205  return new Bscript::BLong( 1 );
206  }
207  else
208  return new Bscript::BError( "Element not found" );
209 }
210 
212 {
213  std::unique_ptr<Bscript::ObjArray> arr( new Bscript::ObjArray );
214 
215  for ( ElementsByString::const_iterator citr = elements_by_string.begin();
216  citr != elements_by_string.end(); ++citr )
217  {
218  arr->addElement( new Bscript::String( ( *citr ).first ) );
219  }
220 
221  for ( ElementsByInteger::const_iterator citr = elements_by_integer.begin();
222  citr != elements_by_integer.end(); ++citr )
223  {
224  arr->addElement( new Bscript::BLong( ( *citr ).first ) );
225  }
226 
227  return arr.release();
228 }
229 
230 
232  : DataFileRefObjImpBase( &datafileref_type, dfcontents )
233 {
234 }
235 
236 const char* DataFileRefObjImp::typeOf() const
237 {
238  return "DataFileRef";
239 }
241 {
242  return OTDataFileRef;
243 }
244 
246 {
247  return new DataFileRefObjImp( obj_ );
248 }
249 
251  bool /*forcebuiltin*/ )
252 {
253  switch ( id )
254  {
256  if ( !ex.hasParams( 1 ) )
257  {
258  return new Bscript::BError( "not enough parameters to datafile.createelement(key)" );
259  }
260  if ( obj_->dsf->flags & DF_KEYTYPE_INTEGER )
261  {
262  int key;
263  if ( !ex.getParam( 0, key ) )
264  {
265  return new Bscript::BError( "datafile.createelement(key): key must be an Integer" );
266  }
267  return obj_->methodCreateElement( key );
268  }
269  else
270  {
271  const Bscript::String* key;
272  if ( !ex.getStringParam( 0, key ) )
273  {
274  return new Bscript::BError( "datafile.createelement(key): key must be a String" );
275  }
276  return obj_->methodCreateElement( key->value() );
277  }
278  break;
280  if ( !ex.hasParams( 1 ) )
281  {
282  return new Bscript::BError( "not enough parameters to datafile.findelement(key)" );
283  }
284  if ( obj_->dsf->flags & DF_KEYTYPE_INTEGER )
285  {
286  int key;
287  if ( !ex.getParam( 0, key ) )
288  {
289  return new Bscript::BError( "datafile.findelement(key): key must be an Integer" );
290  }
291  return obj_->methodFindElement( key );
292  }
293  else
294  {
295  const Bscript::String* key;
296  if ( !ex.getStringParam( 0, key ) )
297  {
298  return new Bscript::BError( "datafile.findelement(key): key must be a String" );
299  }
300  return obj_->methodFindElement( key->value() );
301  }
302  break;
304  if ( !ex.hasParams( 1 ) )
305  {
306  return new Bscript::BError( "not enough parameters to datafile.deleteelement(key)" );
307  }
308  if ( obj_->dsf->flags & DF_KEYTYPE_INTEGER )
309  {
310  int key;
311  if ( !ex.getParam( 0, key ) )
312  {
313  return new Bscript::BError( "datafile.deleteelement(key): key must be an Integer" );
314  }
315  return obj_->methodDeleteElement( key );
316  }
317  else
318  {
319  const Bscript::String* key;
320  if ( !ex.getStringParam( 0, key ) )
321  {
322  return new Bscript::BError( "datafile.deleteelement(key): key must be a String" );
323  }
324  return obj_->methodDeleteElement( key->value() );
325  }
326  break;
327  case Bscript::MTH_KEYS:
328  return obj_->methodKeys();
329  default:
330  return NULL;
331  }
332 }
333 
335 {
336  Bscript::ObjMethod* objmethod = Bscript::getKnownObjMethod( methodname );
337  if ( objmethod != NULL )
338  return this->call_method_id( objmethod->id, ex );
339  else
340  return NULL;
341 }
342 
343 
345  : DataElemRefObjImpBase( &datafileelem_type, DataFileElemObj( dfcontents, dfelem ) )
346 {
347 }
348 const char* DataElemRefObjImp::typeOf() const
349 {
350  return "DataElemRef";
351 }
353 {
354  return OTDataElemRef;
355 }
357 {
358  return new DataElemRefObjImp( obj_.dfcontents, obj_.dfelem );
359 }
360 
362  bool /*forcebuiltin*/ )
363 {
364  bool changed = false;
365  Bscript::BObjectImp* res = CallPropertyListMethod_id( obj_.dfelem->proplist, id, ex, changed );
366  if ( changed )
367  obj_.dfcontents->dirty = true;
368  return res;
369 }
370 
372 {
373  bool changed = false;
374  Bscript::BObjectImp* res =
375  CallPropertyListMethod( obj_.dfelem->proplist, methodname, ex, changed );
376  if ( changed )
377  obj_.dfcontents->dirty = true;
378  return res;
379 }
380 
382  : Bscript::TmplExecutorModule<DataFileExecutorModule>( "datafile", exec )
383 {
384 }
385 
387 {
388  std::string descriptor;
389 
390  const Plib::Package* spec_pkg = NULL;
391  std::string spec_filename;
392  if ( !Plib::pkgdef_split( inspec, exec.prog()->pkg, &spec_pkg, &spec_filename ) )
393  {
394  return NULL; // new BError( "Error in descriptor" );
395  }
396  if ( spec_pkg == NULL )
397  {
398  // ::filename
399  descriptor = "::" + spec_filename;
400  }
401  else
402  {
403  // :somepkg:filename
404  descriptor = ":" + spec_pkg->name() + ":" + spec_filename;
405  }
406 
407  Core::DataStore::iterator itr = Core::configurationbuffer.datastore.find( descriptor );
408  if ( itr != Core::configurationbuffer.datastore.end() )
409  {
410  DataStoreFile* dsf = ( *itr ).second;
411  return dsf;
412  }
413  else
414  {
415  return NULL;
416  }
417 }
418 
420 {
421  std::unique_ptr<Bscript::ObjArray> file_list( new Bscript::ObjArray );
422  for ( Core::DataStore::iterator itr = Core::configurationbuffer.datastore.begin();
423  itr != Core::configurationbuffer.datastore.end(); ++itr )
424  {
425  DataStoreFile* dsf = ( *itr ).second;
426  std::unique_ptr<Bscript::BStruct> file_name( new Bscript::BStruct );
427  file_name->addMember( "pkg", new Bscript::String( dsf->pkgname ) );
428  file_name->addMember( "name", new Bscript::String( dsf->name ) );
429  file_name->addMember( "descriptor", new Bscript::String( dsf->descriptor ) );
430 
431  file_list->addElement( file_name.release() );
432  }
433  return file_list.release();
434 }
435 
437 {
438  const Bscript::String* strob;
439  int flags;
440  if ( getStringParam( 0, strob ) && getParam( 1, flags ) )
441  {
442  try
443  {
444  std::string descriptor;
445  std::string directory;
446  std::string d_ds;
447  const std::string& inspec = strob->value();
448 
449  const Plib::Package* spec_pkg = NULL;
450  std::string spec_filename;
451  if ( !Plib::pkgdef_split( inspec, exec.prog()->pkg, &spec_pkg, &spec_filename ) )
452  {
453  return new Bscript::BError( "Error in descriptor" );
454  }
455  if ( spec_pkg == NULL )
456  {
457  // ::filename
458  descriptor = "::" + spec_filename;
459  directory = Plib::systemstate.config.world_data_path + "ds/";
460  }
461  else
462  {
463  // :somepkg:filename
464  descriptor = ":" + spec_pkg->name() + ":" + spec_filename;
466  directory = Plib::systemstate.config.world_data_path + "ds/" + spec_pkg->name() + "/";
467  }
468  if ( !Clib::FileExists( directory.c_str() ) )
469  {
470  if ( !d_ds.empty() )
471  Clib::MakeDirectory( d_ds.c_str() );
472  Clib::MakeDirectory( directory.c_str() );
473  }
474 
475  DataStoreFile* dsf = NULL;
476 
477  Core::DataStore::iterator itr = Core::configurationbuffer.datastore.find( descriptor );
478  if ( itr != Core::configurationbuffer.datastore.end() )
479  {
480  dsf = ( *itr ).second;
481  }
482  else
483  {
484  // create a new one
485  dsf = new DataStoreFile( descriptor, spec_pkg, spec_filename, flags );
486  Core::configurationbuffer.datastore[descriptor] = dsf;
487  }
488 
489  // didn't find it, time to go open or create.
490  if ( !dsf->loaded() )
491  dsf->load();
492 
493  return new DataFileRefObjImp( dsf->dfcontents );
494  }
495  catch ( std::exception& ex )
496  {
497  std::string message = std::string( "An exception occurred: " ) + ex.what();
498  return new Bscript::BError( message );
499  }
500  }
501  else
502  {
503  return new Bscript::BError( "Invalid parameter type" );
504  }
505 }
506 
508 {
509  const Bscript::String* strob;
510  if ( getStringParam( 0, strob ) )
511  {
512  try
513  {
514  std::string descriptor;
515  // string directory;
516  const std::string& inspec = strob->value();
517 
518  const Plib::Package* spec_pkg = NULL;
519  std::string spec_filename;
520  if ( !Plib::pkgdef_split( inspec, exec.prog()->pkg, &spec_pkg, &spec_filename ) )
521  {
522  return new Bscript::BError( "Error in descriptor" );
523  }
524  if ( spec_pkg == NULL )
525  {
526  // ::filename
527  descriptor = "::" + spec_filename;
528  }
529  else
530  {
531  // :somepkg:filename
532  descriptor = ":" + spec_pkg->name() + ":" + spec_filename;
533  }
534 
535  Core::DataStore::iterator itr = Core::configurationbuffer.datastore.find( descriptor );
536  if ( itr != Core::configurationbuffer.datastore.end() )
537  {
538  DataStoreFile* dsf = ( *itr ).second;
539  // didn't find it, time to go open or create.
540  if ( !dsf->loaded() )
541  dsf->load();
542  return new DataFileRefObjImp( dsf->dfcontents );
543  }
544  else
545  {
546  return new Bscript::BError( "Datafile does not exist" );
547  }
548  }
549  catch ( std::exception& ex )
550  {
551  return new Bscript::BError( std::string( "An exception occurred" ) + ex.what() );
552  }
553  }
554  else
555  {
556  return new Bscript::BError( "Invalid parameter type" );
557  }
558 }
559 
561 {
562  const Bscript::String* strob;
563  if ( getStringParam( 0, strob ) )
564  {
565  DataStoreFile* dsf = GetDataStoreFile( strob->value() );
566  if ( !dsf )
567  return new Bscript::BError( "Unable to find data store file" );
568 
569  dsf->unload = true;
570  return new Bscript::BLong( 1 );
571  }
572  else
573  {
574  return new Bscript::BError( "Invalid parameter type" );
575  }
576 }
577 
579  : descriptor( elem.remove_string( "Descriptor" ) ),
580  name( elem.remove_string( "name" ) ),
581  pkgname( elem.remove_string( "package", "" ) ),
582  pkg( Plib::find_package( pkgname ) ),
583  version( elem.remove_ushort( "Version" ) ),
584  oldversion( elem.remove_ushort( "OldVersion" ) ),
585  flags( elem.remove_ulong( "Flags" ) ),
586  unload( false ),
587  delversion( 0 )
588 {
589 }
590 
592  const std::string& name, int flags )
593  : descriptor( descriptor ),
594  name( name ),
595  pkgname( "" ),
596  pkg( pkg ),
597  version( 0 ),
598  oldversion( 0 ),
599  flags( flags ),
600  unload( false ),
601  delversion( 0 )
602 {
603  if ( pkg != NULL )
604  pkgname = pkg->name();
605 }
606 
608 {
609  return dfcontents.get() != NULL;
610 }
611 
613 {
614  if ( loaded() )
615  return;
616 
617  dfcontents.set( new DataFileContents( this ) );
618 
619  std::string fn = filename();
620  if ( Clib::FileExists( fn.c_str() ) )
621  {
622  Clib::ConfigFile cf( filename().c_str(), "Element" );
623  dfcontents->load( cf );
624  }
625  else
626  {
627  // just force an empty file to be written
628  dfcontents->dirty = true;
629  }
630 }
631 
633 {
634  dfcontents.clear();
635 }
636 
638 {
639  sw() << "DataFile\n"
640  << "{\n"
641  << "\tDescriptor\t" << descriptor << "\n"
642  << "\tName\t" << name << "\n";
643 
644  if ( !pkgname.empty() )
645  sw() << "\tPackage\t" << pkgname << "\n";
646 
647  sw() << "\tFlags\t" << flags << "\n"
648  << "\tVersion\t" << version << "\n"
649  << "\tOldVersion\t" << oldversion << "\n"
650  << "}\n\n";
651 }
652 
653 std::string DataStoreFile::filename( unsigned ver ) const
654 {
655  std::string tmp = Plib::systemstate.config.world_data_path + "ds/";
656  if ( pkg != NULL )
657  tmp += pkg->name() + "/";
658  tmp += name + "." + Clib::tostring( ver % 10 ) + ".txt";
659  return tmp;
660 }
661 
662 std::string DataStoreFile::filename() const
663 {
664  return filename( version );
665 }
666 
668 {
669  std::string fname = filename();
670  std::ofstream ofs( fname.c_str(), std::ios::out );
671  Clib::OFStreamWriter sw( &ofs );
672  dfcontents->save( sw );
673 }
674 
676 {
677  size_t size = descriptor.capacity() + name.capacity() + pkgname.capacity() +
678  sizeof( Plib::Package* ) /*pkg*/
679  + 3 * sizeof( unsigned ) /*version oldversion delversion*/
680  + sizeof( int ) /*flags*/
681  + sizeof( bool ) /*unload*/
682  + sizeof( DataFileContentsRef );
683  if ( dfcontents.get() )
684  size += dfcontents->estimateSize();
685  return size;
686 }
687 
688 
689 DataFileElement::DataFileElement() : proplist( Core::CPropProfiler::Type::DATAFILEELEMENT ) {}
690 
692  : proplist( Core::CPropProfiler::Type::DATAFILEELEMENT )
693 {
695 }
696 
698 {
700 }
701 
703 {
704  std::string datastorefile = Plib::systemstate.config.world_data_path + "datastore.txt";
705 
706  if ( !Clib::FileExists( datastorefile ) )
707  return;
708 
709  Clib::ConfigFile cf( datastorefile, "DataFile" );
710  Clib::ConfigElem elem;
711 
712  while ( cf.read( elem ) )
713  {
714  DataStoreFile* dsf = new DataStoreFile( elem );
716  }
717 }
718 
720 {
721  for ( Core::DataStore::iterator itr = Core::configurationbuffer.datastore.begin();
722  itr != Core::configurationbuffer.datastore.end(); ++itr )
723  {
724  DataStoreFile* dsf = ( *itr ).second;
725 
726  dsf->delversion = dsf->oldversion;
727  dsf->oldversion = dsf->version;
728 
729  if ( dsf->dfcontents.get() && dsf->dfcontents->dirty )
730  {
731  // make a new generation of file and write it.
732  ++dsf->version;
733 
734  dsf->save();
735 
736  dsf->dfcontents->dirty = false;
737  }
738 
739  dsf->printOn( sw );
740  // sw.flush();
741  }
742 }
743 
745 {
746  for ( Core::DataStore::iterator itr = Core::configurationbuffer.datastore.begin();
747  itr != Core::configurationbuffer.datastore.end(); ++itr )
748  {
749  DataStoreFile* dsf = ( *itr ).second;
750 
751  if ( dsf->delversion != dsf->version && dsf->delversion != dsf->oldversion )
752  {
753  Clib::RemoveFile( dsf->filename( dsf->delversion ) );
754  }
755 
756  if ( dsf->unload )
757  {
758  if ( dsf->dfcontents.get() != NULL )
759  {
760  if ( dsf->dfcontents->count() == 1 )
761  {
762  dsf->dfcontents.clear();
763  }
764  }
765  dsf->unload = false;
766  }
767  }
768 }
769 }
770 }
Bscript::BObjectImp * methodDeleteElement(int key)
Definition: datastore.cpp:189
unsigned char u8
Definition: rawtypes.h:25
DataFileContentsRef dfcontents
Definition: datastoreimp.h:152
ElementsByInteger elements_by_integer
Definition: datastoreimp.h:74
const EScriptProgram * prog() const
Definition: executor.h:423
const std::string & value() const
Definition: impstr.h:67
void MakeDirectory(const char *dir)
Definition: fileutil.cpp:62
SystemState systemstate
Definition: systemstate.cpp:12
Bscript::BObjectImp * mf_UnloadDataFile()
Definition: datastore.cpp:560
DataFileContents(DataStoreFile *dsf)
Definition: datastore.cpp:61
Core::PolConfig config
Definition: systemstate.h:43
Bscript::BApplicObjType datafileelem_type
Definition: datastore.cpp:59
std::string world_data_path
Definition: polcfg.h:28
Bscript::BObjectImp * mf_CreateDataFile()
Definition: datastore.cpp:436
ElementsByString elements_by_string
Definition: datastoreimp.h:73
T * get() const
Definition: refptr.h:175
bool getParam(unsigned param, int &value)
Definition: execmodl.cpp:62
DataElemRefObjImp(DataFileContentsRef dfcontents, DataFileElementRef dflem)
Definition: datastore.cpp:344
Bscript::BObjectImp * methodFindElement(int key)
Definition: datastore.cpp:160
virtual Bscript::BObjectImp * call_method_id(const int id, Bscript::Executor &ex, bool forcebuiltin=false) POL_OVERRIDE
Definition: datastore.cpp:361
Bscript::BObjectImp * methodCreateElement(int key)
Definition: datastore.cpp:125
const std::string & name() const
Definition: pkg.h:83
ref_ptr< DataFileElement > DataFileElementRef
Definition: datastoreimp.h:40
ObjMethod * getKnownObjMethod(const char *token)
Definition: parser.cpp:665
DataFileExecutorModule(Bscript::Executor &exec)
Definition: datastore.cpp:381
Package * find_package(const std::string &pkgname)
Definition: pkg.cpp:33
ref_ptr< DataFileContents > DataFileContentsRef
Definition: datastoreimp.h:76
std::string filename() const
Definition: datastore.cpp:662
const char * rest() const
Definition: cfgfile.cpp:84
Bscript::BObjectImp * mf_OpenDataFile()
Definition: datastore.cpp:507
void readRemainingPropertiesAsStrings(Clib::ConfigElem &elem)
Definition: proplist.cpp:487
Bscript::BObjectImp * CallPropertyListMethod_id(PropertyList &proplist, const int id, Bscript::Executor &ex, bool &changed)
Definition: proplist.cpp:520
bool pkgdef_split(const std::string &spec, const Package *inpkg, const Package **outpkg, std::string *path)
Definition: pkg.cpp:410
virtual Bscript::BObjectImp * call_method_id(const int id, Bscript::Executor &ex, bool forcebuiltin=false) POL_OVERRIDE
Definition: datastore.cpp:250
void clear()
Definition: refptr.h:282
virtual const char * typeOf() const POL_OVERRIDE
Definition: datastore.cpp:348
void save(Clib::StreamWriter &sw)
Definition: datastore.cpp:104
DataStoreFile * GetDataStoreFile(const std::string &inspec)
Definition: datastore.cpp:386
size_t estimateSize() const
Definition: datastore.cpp:675
DataFileRefObjImp(DataFileContentsRef dfref)
Definition: datastore.cpp:231
ConfigurationBuffer configurationbuffer
Definition: ucfg.cpp:13
Core::PropertyList proplist
Definition: datastoreimp.h:38
std::string tostring(const Bscript::BTokenType &v)
Definition: tokens.cpp:19
virtual u8 typeOfInt() const POL_OVERRIDE
Definition: datastore.cpp:240
Bscript::BObjectImp * methodKeys() const
Definition: datastore.cpp:211
void load(Clib::ConfigFile &cf)
Definition: datastore.cpp:85
void printPropertiesAsStrings(Clib::StreamWriter &sw) const
Definition: proplist.cpp:452
DataStoreFile(Clib::ConfigElem &elem)
Definition: datastore.cpp:578
const Plib::Package * pkg
Definition: datastoreimp.h:144
Bscript::BApplicObjType datafileref_type
Datastore.
Definition: datastore.cpp:58
void commit_datastore()
Definition: datastore.cpp:744
const String * getStringParam(unsigned param)
Definition: execmodl.cpp:36
void write_datastore(Clib::StreamWriter &sw)
Definition: datastore.cpp:719
size_t estimateSize() const
Definition: datastore.cpp:69
Plib::Package const * pkg
Definition: eprog.h:123
virtual const char * typeOf() const POL_OVERRIDE
Definition: datastore.cpp:236
virtual Bscript::BObjectImp * call_method(const char *methodname, Bscript::Executor &ex) POL_OVERRIDE
Definition: datastore.cpp:371
const String * getStringParam(unsigned param)
Definition: executor.cpp:347
virtual Bscript::BObjectImp * call_method(const char *methodname, Bscript::Executor &ex) POL_OVERRIDE
Definition: datastore.cpp:334
virtual Bscript::BObjectImp * copy() const POL_OVERRIDE
Definition: datastore.cpp:356
void RemoveFile(const std::string &fname)
Definition: fileutil.cpp:143
std::string name
Definition: osmod.cpp:943
Bscript::BObjectImp * mf_ListDataFiles()
Definition: datastore.cpp:419
void read_datastore_dat()
Definition: datastore.cpp:702
bool hasParams(unsigned howmany) const
Definition: executor.h:144
Bscript::BObjectImp * CallPropertyListMethod(PropertyList &proplist, const char *methodname, Bscript::Executor &ex, bool &changed)
Definition: proplist.cpp:591
virtual u8 typeOfInt() const POL_OVERRIDE
Definition: datastore.cpp:352
bool FileExists(const char *filename)
Definition: fileutil.cpp:118
void set(T *ptr)
Definition: refptr.h:275
const int DF_KEYTYPE_INTEGER
Definition: datastoreimp.h:43
bool read(ConfigElem &elem)
Definition: cfgfile.cpp:1047
virtual Bscript::BObjectImp * copy() const POL_OVERRIDE
Definition: datastore.cpp:245
void printOn(Clib::StreamWriter &sw) const
Definition: datastore.cpp:637
Definition: berror.cpp:12
void printOn(Clib::StreamWriter &sw) const
Definition: datastore.cpp:697
bool getParam(unsigned param, int &value)
Definition: executor.cpp:363