core/systems/PluginInfoDatabase.h
author Scott Ehlert <ds@alliedmods.net>
Sun Mar 30 07:00:22 2008 +0000 (2008-03-30)
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Spring Cleaning, Part Ichi (1)
Various minor things done to project files
Updated sample extension project file and updated makefile to the new unified version (more changes likely on the way)
Updated regex project file and makefile
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #ifndef _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
    33 #define _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
    34 
    35 /**
    36  * This file parses plugin_settings.cfg and stores the information in cached memory.
    37  * It provides simplistic abstraction to retrieving the info.
    38  * :TODO: currently untested
    39  */
    40 
    41 #include "sm_memtable.h"
    42 #include "ITextParsers.h"
    43 #include "IPluginSys.h"
    44 #include "sm_globals.h"
    45 
    46 struct PluginOpts
    47 {
    48 	int key;
    49 	int val;
    50 };
    51 
    52 struct PluginSettings
    53 {
    54 	void Init();
    55 	int name;
    56 	bool pause_val;
    57 	PluginType type_val;
    58 	int optarray;
    59 	size_t opts_num;
    60 	size_t opts_size;
    61 	bool blockload_val;
    62 };
    63 
    64 class CPluginInfoDatabase : public ITextListener_SMC
    65 {
    66 public:
    67 	CPluginInfoDatabase();
    68 	~CPluginInfoDatabase();
    69 public: //ITextListener_SMC
    70 	void ReadSMC_ParseStart();
    71 	SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
    72 	SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
    73 	SMCResult ReadSMC_LeavingSection(const SMCStates *states);
    74 public:
    75 	/**
    76 	 * Returns the number of plugin settings available.
    77 	 */
    78 	unsigned int GetSettingsNum();
    79 
    80 	/** 
    81 	 * Given an index, returns the plugin settings block if the filename matches.
    82 	 * Otherwise, returns NULL.
    83 	 */
    84 	PluginSettings *GetSettingsIfMatch(unsigned int index, const char *filename);
    85 
    86 	/** 
    87 	 *  Given a plugin settings struct and an index,
    88 	 * returns the given JIT key/value option pair at that index.
    89 	 * If the input is invalid, key and val will be set to NULL.
    90 	 */
    91 	void GetOptionsForPlugin(PluginSettings *settings, unsigned int opt_num, const char **key, const char **val);
    92 private:
    93 	SMCResult MakeError(const char *fmt, ...);
    94 private:
    95 	BaseStringTable *m_strtab;
    96 	int m_errmsg;
    97 	bool in_plugins;
    98 	bool in_options;
    99 	int m_infodb;
   100 	size_t m_infodb_count;
   101 	size_t m_infodb_size;
   102 	int cur_plugin;
   103 };
   104 
   105 
   106 #endif //_INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_