uox3/source/cServerDefinitions.h
2022-06-17 20:58:32 -04:00

89 lines
2.7 KiB
C++

#ifndef __CSERVERDEFINITIONS__
#define __CSERVERDEFINITIONS__
#include <stack>
typedef std::vector< Script * > VECSCRIPTLIST;
typedef std::vector< Script * >::iterator VECSCRIPTLIST_ITERATOR;
typedef std::vector< Script * >::const_iterator VECSCRIPTLIST_CITERATOR;
typedef std::stack< std::string > dirList;
class cDirectoryListing {
private:
typedef std::vector< cDirectoryListing > DIRLIST;
typedef std::vector< cDirectoryListing >::iterator DIRLIST_ITERATOR;
auto PushDir(DEFINITIONCATEGORIES toMove) ->bool;
auto PushDir(std::string toMove) ->bool;
auto PopDir() ->void;
std::vector< std::string > filenameList, shortList;
std::vector< std::string > flattenedShort, flattenedFull;
dirList dirs;
std::string extension;
std::string currentDir;
std::string shortCurrentDir;
DIRLIST subdirectories;
bool doRecursion;
void InternalRetrieve();
public:
cDirectoryListing( bool recurse = true );
cDirectoryListing( const std::string &dir, const std::string &extent, bool recurse = true );
cDirectoryListing( DEFINITIONCATEGORIES dir, const std::string &extent, bool recurse = true );
~cDirectoryListing();
auto Extension(const std::string &extent) ->void;
auto Retrieve(const std::string &dir) ->void;
auto Retrieve(DEFINITIONCATEGORIES dir) ->void;
auto Flatten(bool isParent) ->void;
auto ClearFlatten() ->void;
auto List() ->std::vector< std::string >*;
auto ShortList() ->std::vector< std::string >*;
auto FlattenedList() ->std::vector< std::string >*;
auto FlattenedShortList() ->std::vector< std::string >*;
};
class CServerDefinitions {
private:
VECSCRIPTLIST_ITERATOR slIter;
std::map< std::string, SI16 > priorityMap;
SI16 defaultPriority;
auto LoadDFNCategory(DEFINITIONCATEGORIES toLoad) ->void;
auto ReloadScriptObjects() ->void;
auto BuildPriorityMap(DEFINITIONCATEGORIES category, UI08 &wasPrioritized) ->void;
auto CleanPriorityMap() ->void;
auto GetPriority(const char *file) ->std::int16_t;
auto Cleanup() ->void;
public:
std::vector< VECSCRIPTLIST > ScriptListings;
CServerDefinitions();
~CServerDefinitions();
auto startup() ->void ;
auto Reload() ->bool;
auto Dispose(DEFINITIONCATEGORIES toDispose) ->bool;
auto FindEntry(const std::string &toFind, DEFINITIONCATEGORIES typeToFind) ->ScriptSection* ;
auto FindEntrySubStr(const std::string &toFind, DEFINITIONCATEGORIES typeToFind) ->ScriptSection* ;
auto CountOfEntries(DEFINITIONCATEGORIES typeToFind) ->size_t ;
auto CountOfFiles(DEFINITIONCATEGORIES typeToFind) ->size_t ;
auto DisplayPriorityMap() ->void;
auto FirstScript(DEFINITIONCATEGORIES typeToFind) ->Script* ;
auto NextScript(DEFINITIONCATEGORIES typeToFind) ->Script* ;
auto FinishedScripts( DEFINITIONCATEGORIES typeToFind) ->bool;
};
extern CServerDefinitions *FileLookup;
#endif