core/systems/PluginInfoDatabase.h
author Borja Ferrer <faluco@alliedmods.net>
Thu Jul 05 14:47:36 2007 +0000 (2007-07-05)
changeset 1041 f7b2073013df
parent 653 ef60870067ff
child 1231 17badaf66ce4
permissions -rw-r--r--
added a time stamp argument to FormatTime
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  * This file is not open source and may not be copied without explicit
     8  * written permission of AlliedModders LLC.  This file may not be redistributed 
     9  * in whole or significant part.
    10  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
    16 #define _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
    17 
    18 /**
    19  * This file parses plugin_settings.cfg and stores the information in cached memory.
    20  * It provides simplistic abstraction to retrieving the info.
    21  * :TODO: currently untested
    22  */
    23 
    24 #include "sm_memtable.h"
    25 #include "ITextParsers.h"
    26 #include "IPluginSys.h"
    27 #include "sm_globals.h"
    28 
    29 struct PluginOpts
    30 {
    31 	int key;
    32 	int val;
    33 };
    34 
    35 struct PluginSettings
    36 {
    37 	void Init();
    38 	int name;
    39 	bool pause_val;
    40 	PluginType type_val;
    41 	int optarray;
    42 	size_t opts_num;
    43 	size_t opts_size;
    44 };
    45 
    46 class CPluginInfoDatabase : public ITextListener_SMC
    47 {
    48 public:
    49 	CPluginInfoDatabase();
    50 	~CPluginInfoDatabase();
    51 public: //ITextListener_SMC
    52 	void ReadSMC_ParseStart();
    53 	SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
    54 	SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
    55 	SMCParseResult ReadSMC_LeavingSection();
    56 public:
    57 	/**
    58 	 * Returns the number of plugin settings available.
    59 	 */
    60 	unsigned int GetSettingsNum();
    61 
    62 	/** 
    63 	 * Given an index, returns the plugin settings block if the filename matches.
    64 	 * Otherwise, returns NULL.
    65 	 */
    66 	PluginSettings *GetSettingsIfMatch(unsigned int index, const char *filename);
    67 
    68 	/** 
    69 	 *  Given a plugin settings struct and an index,
    70 	 * returns the given JIT key/value option pair at that index.
    71 	 * If the input is invalid, key and val will be set to NULL.
    72 	 */
    73 	void GetOptionsForPlugin(PluginSettings *settings, unsigned int opt_num, const char **key, const char **val);
    74 private:
    75 	SMCParseResult MakeError(const char *fmt, ...);
    76 private:
    77 	BaseStringTable *m_strtab;
    78 	int m_errmsg;
    79 	bool in_plugins;
    80 	bool in_options;
    81 	int m_infodb;
    82 	size_t m_infodb_count;
    83 	size_t m_infodb_size;
    84 	int cur_plugin;
    85 };
    86 
    87 
    88 #endif //_INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_