core/systems/PluginInfoDatabase.h
author David Anderson <dvander@alliedmods.net>
Wed Jan 17 03:01:38 2007 +0000 (2007-01-17)
changeset 304 fa485d2f25ed
parent 203 c7f86f9e6f60
child 351 7c219cde57e7
permissions -rw-r--r--
Added extension loading/unloading
Extended SDK for interface sharing
Completed Metamod extension support
     1 #ifndef _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
     2 #define _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
     3 
     4 /**
     5  * This file parses plugin_settings.cfg and stores the information in cached memory.
     6  * It provides simplistic abstraction to retrieving the info.
     7  * :TODO: currently untested
     8  */
     9 
    10 #include "sm_memtable.h"
    11 #include "ITextParsers.h"
    12 #include "IPluginSys.h"
    13 #include "sm_globals.h"
    14 
    15 struct PluginOpts
    16 {
    17 	int key;
    18 	int val;
    19 };
    20 
    21 struct PluginSettings
    22 {
    23 	void Init();
    24 	int name;
    25 	bool pause_val;
    26 	PluginType type_val;
    27 	int optarray;
    28 	size_t opts_num;
    29 	size_t opts_size;
    30 };
    31 
    32 class CPluginInfoDatabase : public ITextListener_SMC
    33 {
    34 public:
    35 	CPluginInfoDatabase();
    36 	~CPluginInfoDatabase();
    37 public: //ITextListener_SMC
    38 	void ReadSMC_ParseStart();
    39 	SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
    40 	SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
    41 	SMCParseResult ReadSMC_LeavingSection();
    42 public:
    43 	/**
    44 	 * Returns the number of plugin settings available.
    45 	 */
    46 	unsigned int GetSettingsNum();
    47 
    48 	/** 
    49 	 * Given an index, returns the plugin settings block if the filename matches.
    50 	 * Otherwise, returns NULL.
    51 	 */
    52 	PluginSettings *GetSettingsIfMatch(unsigned int index, const char *filename);
    53 
    54 	/** 
    55 	 *  Given a plugin settings struct and an index,
    56 	 * returns the given JIT key/value option pair at that index.
    57 	 * If the input is invalid, key and val will be set to NULL.
    58 	 */
    59 	void GetOptionsForPlugin(PluginSettings *settings, unsigned int opt_num, const char **key, const char **val);
    60 private:
    61 	SMCParseResult MakeError(const char *fmt, ...);
    62 private:
    63 	BaseStringTable *m_strtab;
    64 	int m_errmsg;
    65 	bool in_plugins;
    66 	bool in_options;
    67 	unsigned int m_infodb;
    68 	size_t m_infodb_count;
    69 	size_t m_infodb_size;
    70 	int cur_plugin;
    71 };
    72 
    73 
    74 #endif //_INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_