dvander@372: /** ds@653: * vim: set ts=4 : dvander@372: * =============================================================== dvander@372: * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. dvander@372: * =============================================================== dvander@372: * dvander@379: * This file is part of the SourceMod/SourcePawn SDK. This file may only be dvander@379: * used or modified under the Terms and Conditions of its License Agreement, dvander@379: * which is found in public/licenses/LICENSE.txt. As of this notice, derivative dvander@379: * works must be licensed under the GNU General Public License (version 2 or dvander@379: * greater). A copy of the GPL is included under public/licenses/GPL.txt. dvander@379: * dvander@379: * To view the latest information, see: http://www.sourcemod.net/license.php dvander@372: * dvander@372: * Version: $Id$ dvander@372: */ dvander@372: dvander@324: #ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_ dvander@324: #define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_ dvander@324: dvander@372: /** dvander@372: * @file ISourceMod.h ds@729: * @brief Defines miscellaneous helper functions useful to extensions. dvander@372: */ dvander@372: faluco@682: #include dvander@359: #include faluco@484: #include dvander@324: dvander@324: #define SMINTERFACE_SOURCEMOD_NAME "ISourceMod" dvander@735: #define SMINTERFACE_SOURCEMOD_VERSION 3 dvander@324: faluco@682: /** faluco@682: * @brief Forward declaration of the KeyValues class. faluco@682: */ faluco@682: class KeyValues; faluco@682: dvander@324: namespace SourceMod dvander@324: { dvander@372: /** dvander@372: * @brief Describes various ways of formatting a base path. dvander@372: */ dvander@324: enum PathType dvander@324: { dvander@372: Path_None = 0, /**< No base path */ dvander@372: Path_Game, /**< Base path is absolute mod folder */ dvander@372: Path_SM, /**< Base path is absolute to SourceMod */ dvander@372: Path_SM_Rel, /**< Base path is relative to SourceMod */ dvander@324: }; dvander@324: dvander@372: /** faluco@484: * @brief Contains miscellaneous helper functions. dvander@372: */ dvander@324: class ISourceMod : public SMInterface dvander@324: { dvander@324: public: dvander@324: virtual const char *GetInterfaceName() dvander@324: { dvander@324: return SMINTERFACE_SOURCEMOD_NAME; dvander@324: } dvander@324: virtual unsigned int GetInterfaceVersion() dvander@324: { dvander@324: return SMINTERFACE_SOURCEMOD_VERSION; dvander@324: } dvander@324: public: dvander@324: /** ds@729: * @brief Returns the full path to the game directory. dvander@324: * ds@729: * @return A string containing the full game path. dvander@324: */ ds@729: virtual const char *GetGamePath() const =0; dvander@324: dvander@324: /** dvander@324: * @brief Returns the full path to the SourceMod directory. dvander@324: * dvander@324: * @return A string containing the full SourceMod path. dvander@324: */ faluco@484: virtual const char *GetSourceModPath() const =0; dvander@324: dvander@324: /** dvander@324: * @brief Builds a platform path for a specific target base path. dvander@324: * dvander@324: * @param type Type of path to use as a base. dvander@324: * @param buffer Buffer to write to. dvander@324: * @param maxlength Size of buffer. dvander@324: * @param format Format string. dvander@324: * @param ... Format arguments. dvander@324: * @return Number of bytes written. dvander@324: */ dvander@324: virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...) =0; dvander@324: dvander@324: /** dvander@324: * @brief Logs a message to the SourceMod logs. dvander@324: * dvander@372: * @param pExt Extension calling this function. dvander@324: * @param format Message format. dvander@324: * @param ... Message format parameters. dvander@324: */ dvander@324: virtual void LogMessage(IExtension *pExt, const char *format, ...) =0; dvander@324: dvander@324: /** dvander@324: * @brief Logs a message to the SourceMod error logs. dvander@324: * dvander@372: * @param pExt Extension calling this function. dvander@324: * @param format Message format. dvander@324: * @param ... Message format parameters. dvander@324: */ dvander@324: virtual void LogError(IExtension *pExt, const char *format, ...) =0; dvander@347: dvander@347: /** dvander@347: * @brief Formats a string from a native. dvander@347: * dvander@347: * @param buffer Buffer to store message. ds@729: * @param maxlength Maximum length of buffer (including null terminator). dvander@347: * @param pContext Pointer to the plugin's context. dvander@347: * @param params Parameter array that was passed to the native. dvander@347: * @param param Parameter index where format string and variable arguments begin. dvander@416: * Note: parameter indexes start at 1. dvander@347: * @return Number of bytes written, not including the null terminator. dvander@347: */ dvander@347: virtual size_t FormatString(char *buffer, dvander@347: size_t maxlength, dvander@359: SourcePawn::IPluginContext *pContext, dvander@347: const cell_t *params, dvander@347: unsigned int param) =0; dvander@440: dvander@440: /** dvander@440: * @brief Creates a data pack object. dvander@440: * dvander@440: * @return A new IDataPack object. dvander@440: */ dvander@440: virtual IDataPack *CreateDataPack() =0; dvander@440: dvander@440: /** dvander@440: * @brief Releases a data pack's resources so it can be re-used. dvander@440: * dvander@440: * @param pack An IDataPack object to release. dvander@440: */ dvander@440: virtual void FreeDataPack(IDataPack *pack) =0; dvander@440: ds@696: /** ds@696: * @brief Returns the automated data pack handle type. ds@696: * ds@729: * The read-only data type is the parent of the writable type. ds@696: * Note that calling CloseHandle() on either type will release the data pack. ds@729: * The read-only type is inheritable, but due to limitations of the Handle System, ds@696: * the writable type is not. ds@696: * ds@729: * @param readonly If true, the read-only type will be returned. ds@696: * @return The Handle type for storing generic data packs. ds@696: */ ds@696: virtual HandleType_t GetDataPackHandleType(bool readonly=false) =0; faluco@682: ds@696: /** ds@696: * @brief Retrieves a KeyValues pointer from a handle. ds@696: * ds@696: * @param hndl Handle_t from which to retrieve contents. ds@696: * @param err Optional address to store a possible handle error. ds@696: * @param root If true it will return the root KeyValues pointer for the whole structure. ds@696: * ds@696: * @return The KeyValues pointer, or NULL for any error encountered. ds@696: */ ds@696: virtual KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false) =0; ds@696: ds@696: /** ds@729: * @brief Returns the name of the game directory. ds@696: * ds@729: * @return A string containing the name of the game directory. ds@696: */ ds@729: virtual const char *GetGameFolderName() const =0; faluco@733: faluco@733: /** faluco@733: * @brief Returns the scripting engine interface. faluco@733: * faluco@733: * @return A pointer to the scripting engine interface. faluco@733: */ faluco@733: virtual SourcePawn::ISourcePawnEngine *GetScriptingEngine() =0; faluco@733: faluco@733: /** faluco@733: * @brief Returns the JIT interface. faluco@733: * faluco@733: * @return A pointer to the JIT interface. faluco@733: */ faluco@733: virtual SourcePawn::IVirtualMachine *GetScriptingVM() =0; dvander@324: }; ds@432: } dvander@324: dvander@324: #endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_