mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 10:15:47 -04:00
Initial community commit
This commit is contained in:
135
Src/Agave/Config/api_config.h
Normal file
135
Src/Agave/Config/api_config.h
Normal file
@ -0,0 +1,135 @@
|
||||
#ifndef NULLSOFT_AGAVE_API_CONFIG_H
|
||||
#define NULLSOFT_AGAVE_API_CONFIG_H
|
||||
|
||||
#include "bfc/dispatch.h"
|
||||
|
||||
#include "ifc_configgroup.h"
|
||||
|
||||
enum
|
||||
{
|
||||
CONFIG_SUCCESS = 0,
|
||||
CONFIG_FAILURE = 1,
|
||||
CONFIG_GROUPNOTFOUND = 2,
|
||||
CONFIG_ITEMNOTFOUND = 3,
|
||||
};
|
||||
|
||||
class api_config : public Dispatchable
|
||||
{
|
||||
protected:
|
||||
api_config() {}
|
||||
~api_config() {}
|
||||
|
||||
public:
|
||||
ifc_configgroup *GetGroup( GUID groupGUID );
|
||||
void RegisterGroup( ifc_configgroup *newGroup );
|
||||
|
||||
/* Shortcut methods */
|
||||
bool GetBool( GUID groupGUID, const wchar_t *configItem, bool defaultValue );
|
||||
uintptr_t GetUnsigned( GUID groupGUID, const wchar_t *configItem, uintptr_t defaultValue );
|
||||
intptr_t GetInt( GUID groupGUID, const wchar_t *configItem, intptr_t defaultValue );
|
||||
float GetFloat( GUID groupGUID, const wchar_t *configItem, float defaultValue );
|
||||
const wchar_t *GetString( GUID groupGUID, const wchar_t *configItem, const wchar_t *defaultValue );
|
||||
ifc_configitem *GetItem( GUID groupGUID, const wchar_t *configItem );
|
||||
|
||||
DISPATCH_CODES
|
||||
{
|
||||
API_CONFIG_GETGROUP = 10,
|
||||
API_CONFIG_REGISTERGROUP = 20,
|
||||
};
|
||||
};
|
||||
|
||||
inline ifc_configgroup *api_config::GetGroup( GUID groupGUID )
|
||||
{
|
||||
return _call( API_CONFIG_GETGROUP, (ifc_configgroup *)0, groupGUID );
|
||||
}
|
||||
|
||||
inline void api_config::RegisterGroup( ifc_configgroup *newGroup )
|
||||
{
|
||||
_voidcall( API_CONFIG_REGISTERGROUP, newGroup );
|
||||
}
|
||||
|
||||
inline bool api_config::GetBool( GUID groupGUID, const wchar_t *configItem, bool defaultValue )
|
||||
{
|
||||
ifc_configgroup *group = GetGroup( groupGUID );
|
||||
if ( group )
|
||||
{
|
||||
ifc_configitem *item = group->GetItem( configItem );
|
||||
if ( item )
|
||||
return item->GetBool();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline uintptr_t api_config::GetUnsigned( GUID groupGUID, const wchar_t *configItem, uintptr_t defaultValue )
|
||||
{
|
||||
ifc_configgroup *group = GetGroup( groupGUID );
|
||||
if ( group )
|
||||
{
|
||||
ifc_configitem *item = group->GetItem( configItem );
|
||||
if ( item )
|
||||
return item->GetUnsigned();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline intptr_t api_config::GetInt( GUID groupGUID, const wchar_t *configItem, intptr_t defaultValue )
|
||||
{
|
||||
ifc_configgroup *group = GetGroup( groupGUID );
|
||||
if ( group )
|
||||
{
|
||||
ifc_configitem *item = group->GetItem( configItem );
|
||||
if ( item )
|
||||
return item->GetInt();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline float api_config::GetFloat( GUID groupGUID, const wchar_t *configItem, float defaultValue )
|
||||
{
|
||||
ifc_configgroup *group = GetGroup( groupGUID );
|
||||
if ( group )
|
||||
{
|
||||
ifc_configitem *item = group->GetItem( configItem );
|
||||
if ( item )
|
||||
return item->GetFloat();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline const wchar_t *api_config::GetString( GUID groupGUID, const wchar_t *configItem, const wchar_t *defaultValue )
|
||||
{
|
||||
ifc_configgroup *group = GetGroup( groupGUID );
|
||||
if ( group )
|
||||
{
|
||||
ifc_configitem *item = group->GetItem( configItem );
|
||||
if ( item )
|
||||
return item->GetString();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline ifc_configitem *api_config::GetItem( GUID groupGUID, const wchar_t *configItem )
|
||||
{
|
||||
ifc_configgroup *group = GetGroup( groupGUID );
|
||||
if ( group )
|
||||
return group->GetItem( configItem );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// {AEFBF8BE-E0AA-4318-8CC1-4353410B64DC}
|
||||
static const GUID AgaveConfigGUID =
|
||||
{ 0xaefbf8be, 0xe0aa, 0x4318, { 0x8c, 0xc1, 0x43, 0x53, 0x41, 0xb, 0x64, 0xdc } };
|
||||
|
||||
extern api_config *configApi;
|
||||
|
||||
#ifndef AGAVE_API_CONFIG
|
||||
#define AGAVE_API_CONFIG configApi
|
||||
#endif // !AGAVE_API_CONFIG
|
||||
|
||||
#endif
|
36
Src/Agave/Config/ifc_configgroup.h
Normal file
36
Src/Agave/Config/ifc_configgroup.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef NULLSOFT_AGAVE_IFC_CONFIGGROUP_H
|
||||
#define NULLSOFT_AGAVE_IFC_CONFIGGROUP_H
|
||||
|
||||
#include <bfc/dispatch.h>
|
||||
#include <bfc/platform/types.h>
|
||||
#include <bfc/platform/guid.h>
|
||||
#include "ifc_configitem.h"
|
||||
|
||||
class ifc_configgroup : public Dispatchable
|
||||
{
|
||||
protected:
|
||||
ifc_configgroup() {}
|
||||
~ifc_configgroup() {}
|
||||
|
||||
public:
|
||||
ifc_configitem *GetItem( const wchar_t *name );
|
||||
GUID GetGUID();
|
||||
|
||||
DISPATCH_CODES
|
||||
{
|
||||
IFC_CONFIGGROUP_GETITEM = 10,
|
||||
IFC_CONFIGGROUP_GETGUID = 20,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
inline ifc_configitem *ifc_configgroup::GetItem(const wchar_t *name)
|
||||
{
|
||||
return _call(IFC_CONFIGGROUP_GETITEM, (ifc_configitem *)0, name);
|
||||
}
|
||||
|
||||
inline GUID ifc_configgroup::GetGUID()
|
||||
{
|
||||
return _call(IFC_CONFIGGROUP_GETGUID, (GUID)INVALID_GUID);
|
||||
}
|
||||
#endif
|
200
Src/Agave/Config/ifc_configitem.h
Normal file
200
Src/Agave/Config/ifc_configitem.h
Normal file
@ -0,0 +1,200 @@
|
||||
#ifndef NULLSOFT_AGAVE_IFC_CONFIGITEM_H
|
||||
#define NULLSOFT_AGAVE_IFC_CONFIGITEM_H
|
||||
|
||||
#include <bfc/dispatch.h>
|
||||
#include <stddef.h>
|
||||
/*
|
||||
notes:
|
||||
The Set() functions are "public-facing", meaning that they can be called by anyone. If you want to make your config item read-only,
|
||||
then simply don't implement these. You can always make "private" Set functions in your implementation.
|
||||
|
||||
SetStringInternal and GetStringInternal are written for use with classes to load and save from INI files (or XML files or whatever).
|
||||
It's up to you to figure out a clever way to encode yourself.
|
||||
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
CONFIG_ITEM_TYPE_STRING = 0,
|
||||
CONFIG_ITEM_TYPE_INT = 1,
|
||||
CONFIG_ITEM_TYPE_UNSIGNED =2,
|
||||
CONFIG_ITEM_TYPE_BOOL =3,
|
||||
CONFIG_ITEM_TYPE_BINARY =4,
|
||||
CONFIG_ITEM_TYPE_INT_ARRAY = 5,
|
||||
};
|
||||
|
||||
class ifc_configitem : public Dispatchable
|
||||
{
|
||||
protected:
|
||||
ifc_configitem() {}
|
||||
~ifc_configitem() {}
|
||||
public:
|
||||
const wchar_t *GetName();
|
||||
int GetType();
|
||||
|
||||
const wchar_t *GetString();
|
||||
void SetString(const wchar_t *stringValue);
|
||||
|
||||
intptr_t GetInt();
|
||||
void SetInt(intptr_t intValue);
|
||||
|
||||
uintptr_t GetUnsigned();
|
||||
void SetUnsigned(uintptr_t unsignedValue);
|
||||
|
||||
bool GetBool();
|
||||
void SetBool(bool boolValue);
|
||||
|
||||
float GetFloat();
|
||||
void SetFloat(float floatValue);
|
||||
|
||||
size_t GetBinarySize();
|
||||
size_t GetBinaryData(void *data, size_t bytes); // returns bytes written
|
||||
void SetBinaryData(void *data, size_t bytes);
|
||||
|
||||
size_t GetIntArrayElements();
|
||||
size_t GetIntArray(intptr_t *array, size_t elements); // returns elements written
|
||||
void SetIntArray(intptr_t *array, size_t elements);
|
||||
|
||||
const wchar_t *GetStringInternal(); // gets a string suitable for saving in an INI file or XML
|
||||
void SetStringInternal(const wchar_t *internalString);
|
||||
|
||||
public:
|
||||
DISPATCH_CODES
|
||||
{
|
||||
IFC_CONFIGITEM_GETNAME = 10,
|
||||
IFC_CONFIGITEM_GETTYPE = 20,
|
||||
|
||||
IFC_CONFIGITEM_GETSTRING= 30,
|
||||
IFC_CONFIGITEM_SETSTRING= 40,
|
||||
|
||||
IFC_CONFIGITEM_GETINT= 50,
|
||||
IFC_CONFIGITEM_SETINT= 60,
|
||||
|
||||
IFC_CONFIGITEM_GETUNSIGNED= 70,
|
||||
IFC_CONFIGITEM_SETUNSIGNED= 80,
|
||||
|
||||
IFC_CONFIGITEM_GETBOOL= 90,
|
||||
IFC_CONFIGITEM_SETBOOL= 100,
|
||||
|
||||
IFC_CONFIGITEM_GETBINARYSIZE= 110,
|
||||
IFC_CONFIGITEM_GETBINARYDATA= 120,
|
||||
IFC_CONFIGITEM_SETBINARYDATA= 130,
|
||||
|
||||
IFC_CONFIGITEM_GETINTARRAYELEMENTS= 140,
|
||||
IFC_CONFIGITEM_GETINTARRAY= 150,
|
||||
IFC_CONFIGITEM_SETINTARRAY= 160,
|
||||
|
||||
IFC_CONFIGITEM_GETSTRINGINTERNAL= 170,
|
||||
IFC_CONFIGITEM_SETSTRINGINTERNAL= 180,
|
||||
|
||||
IFC_CONFIGITEM_GETFLOAT= 190,
|
||||
IFC_CONFIGITEM_SETFLOAT= 200,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline const wchar_t *ifc_configitem::GetName()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETNAME, (const wchar_t *)0);
|
||||
}
|
||||
|
||||
inline int ifc_configitem::GetType()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETTYPE, (int)0);
|
||||
}
|
||||
|
||||
inline const wchar_t *ifc_configitem::GetString()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETSTRING, (const wchar_t *)0);
|
||||
}
|
||||
|
||||
inline void ifc_configitem::SetString(const wchar_t *stringValue)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETSTRING, stringValue);
|
||||
}
|
||||
|
||||
|
||||
inline intptr_t ifc_configitem::GetInt()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETINT, (intptr_t)0);
|
||||
}
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4244)
|
||||
inline void ifc_configitem::SetInt(intptr_t intValue)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETINT, intValue);
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
inline uintptr_t ifc_configitem::GetUnsigned()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETUNSIGNED, (uintptr_t)0);
|
||||
}
|
||||
|
||||
inline void ifc_configitem::SetUnsigned(uintptr_t unsignedValue)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETUNSIGNED, unsignedValue);
|
||||
}
|
||||
|
||||
|
||||
inline bool ifc_configitem::GetBool()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETBOOL, (bool)false);
|
||||
}
|
||||
|
||||
inline void ifc_configitem::SetBool(bool boolValue)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETBOOL, boolValue);
|
||||
}
|
||||
|
||||
inline size_t ifc_configitem::GetBinarySize()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETBINARYSIZE, (size_t)0);
|
||||
}
|
||||
|
||||
inline size_t ifc_configitem::GetBinaryData(void *data, size_t bytes)
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETBINARYDATA, (size_t)0, data, bytes);
|
||||
}
|
||||
|
||||
inline void ifc_configitem::SetBinaryData(void *data, size_t bytes)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETBINARYDATA, data, bytes);
|
||||
}
|
||||
|
||||
inline size_t ifc_configitem::GetIntArrayElements()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETINTARRAYELEMENTS, (size_t)0);
|
||||
}
|
||||
|
||||
inline size_t ifc_configitem::GetIntArray(intptr_t *array, size_t elements)
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETINTARRAY, (size_t)0, array, elements);
|
||||
}
|
||||
inline void ifc_configitem::SetIntArray(intptr_t *array, size_t elements)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETINTARRAY, array, elements);
|
||||
}
|
||||
|
||||
inline const wchar_t *ifc_configitem::GetStringInternal()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETSTRINGINTERNAL, (const wchar_t *)0);
|
||||
}
|
||||
inline void ifc_configitem::SetStringInternal(const wchar_t *internalString)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETSTRINGINTERNAL, internalString);
|
||||
}
|
||||
|
||||
inline float ifc_configitem::GetFloat()
|
||||
{
|
||||
return _call(IFC_CONFIGITEM_GETFLOAT, (float)0);
|
||||
}
|
||||
|
||||
inline void ifc_configitem::SetFloat(float floatValue)
|
||||
{
|
||||
_voidcall(IFC_CONFIGITEM_SETFLOAT, floatValue);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user