1
0

refactor: add WF prefix for c/c++ binding members

This commit is contained in:
2026-06-17 21:40:19 +08:00
parent 50f01429b0
commit 821b865f2d
5 changed files with 195 additions and 191 deletions

View File

@@ -19,13 +19,13 @@
namespace wfassocpp {
using wfassoc::CStyleString;
using wfassoc::Token;
using wfassoc::HICON;
using wfassoc::INVALID_HICON;
using wfassoc::INVALID_INDEX;
using wfassoc::Scope;
using wfassoc::View;
using CString = wfassoc::WFCString;
using Token = wfassoc::WFToken;
using HICON = wfassoc::WFHICON;
using INVALID_HICON = wfassoc::WF_INVALID_HICON;
using INVALID_INDEX = wfassoc::WF_INVALID_INDEX;
using Scope = wfassoc::WFScope;
using View = wfassoc::WFView;
/// @private
inline void _Check(bool result) {

View File

@@ -28,35 +28,35 @@ namespace wfassoc {
#ifdef __cplusplus
/** Type representing a null-terminated UTF-8 C-style string */
using CStyleString = const char*;
using WFCString = const char*;
/**
* @brief Type representing a handle/token for managed objects
*
* This library use object pool to manage any objects created during calling.
* And we expose this type as an opaque handle for visiting your created object.
*/
using Token = uint64_t;
using WFToken = uint64_t;
/**
* @brief Type representing an icon handle (opaque pointer)
*
* This type is equivalent with Win32 HICON type.
*/
using HICON = void*;
using WFHICON = void*;
#else // __cplusplus
typedef const char *CStyleString;
typedef uint64_t Token;
typedef void *HICON;
typedef const char *WFCString;
typedef uint64_t WFToken;
typedef void *WFHICON;
#endif // __cplusplus
#ifdef __cplusplus
/** Invalid icon handle value */
constexpr HICON INVALID_HICON = nullptr;
constexpr WFHICON WF_INVALID_HICON = nullptr;
/** Invalid index value used for error conditions */
constexpr size_t INVALID_INDEX = static_cast<size_t>(-1);
constexpr size_t WF_INVALID_INDEX = static_cast<size_t>(-1);
#else // __cplusplus
static const HICON INVALID_HICON = NULL;
static const size_t INVALID_INDEX = ((size_t)-1);
static const WFHICON WF_INVALID_HICON = NULL;
static const size_t WF_INVALID_INDEX = ((size_t)-1);
#endif // __cplusplus
@@ -66,7 +66,7 @@ static const size_t INVALID_INDEX = ((size_t)-1);
*
* Determines whether a program is registered for the current user or system-wide.
*/
enum class Scope : uint32_t {
enum class WFScope : uint32_t {
/** Current user scope */
User = 0u,
/** System-wide scope */
@@ -77,7 +77,7 @@ enum class Scope : uint32_t {
*
* Determines how the association status is viewed/queried.
*/
enum class View : uint32_t {
enum class WFView : uint32_t {
/** User-level view */
User = 0u,
/** System-level view */
@@ -86,18 +86,18 @@ enum class View : uint32_t {
Hybrid = 2u
};
#else // __cplusplus
typedef uint32_t Scope;
typedef uint32_t WFScope;
/** Current user scope */
static const Scope SCOPE_USER = 0u;
static const WFScope WF_SCOPE_USER = 0u;
/** System-wide scope */
static const Scope SCOPE_SYSTEM = 1u;
typedef uint32_t View;
static const WFScope WF_SCOPE_SYSTEM = 1u;
typedef uint32_t WFView;
/** User-level view */
static const View VIEW_USER = 0u;
static const WFView WF_VIEW_USER = 0u;
/** System-level view */
static const View VIEW_SYSTEM = 1u;
static const WFView WF_VIEW_SYSTEM = 1u;
/** Combined hybrid view of both user and system */
static const View VIEW_HYBRID = 2u;
static const WFView WF_VIEW_HYBRID = 2u;
#endif // __cplusplus
@@ -143,7 +143,7 @@ bool WFShutdown(void);
* If no error has occurred, the string is empty.
* There is no possibility of a NULL return value.
*/
CStyleString WFGetLastError(void);
WFCString WFGetLastError(void);
/**
* @brief Check if the current process has administrative privileges
@@ -170,7 +170,7 @@ bool WFHasPrivilege(void);
*
* @return An invalid token value
*/
Token WFInvalidToken(void);
WFToken WFInvalidWFToken(void);
/**
* @brief Create a new Schema object
@@ -185,7 +185,7 @@ Token WFInvalidToken(void);
* or consumed by creating a Program object via WFProgramCreate().
* @return true on success, false on failure
*/
bool WFSchemaCreate(Token *out_schema);
bool WFSchemaCreate(WFToken *out_schema);
/**
* @brief Destroy a Schema object
@@ -198,7 +198,7 @@ bool WFSchemaCreate(Token *out_schema);
* @param[in] in_schema Schema token to destroy
* @return true on success, false on failure
*/
bool WFSchemaDestroy(Token in_schema);
bool WFSchemaDestroy(WFToken in_schema);
/**
* @brief Set the program identifier for a Schema
@@ -209,7 +209,7 @@ bool WFSchemaDestroy(Token in_schema);
* and follow with alphabet characters, digits, underline, or hyphens.
* @return true on success, false on failure
*/
bool WFSchemaSetIdentifier(Token in_schema, CStyleString in_value);
bool WFSchemaSetIdentifier(WFToken in_schema, WFCString in_value);
/**
* @brief Set the program path for a Schema
@@ -219,7 +219,7 @@ bool WFSchemaSetIdentifier(Token in_schema, CStyleString in_value);
* This path should be the fully qualified path to the application.
* @return true on success, false on failure
*/
bool WFSchemaSetPath(Token in_schema, CStyleString in_value);
bool WFSchemaSetPath(WFToken in_schema, WFCString in_value);
/**
* @brief Set the program CLSID for a Schema
@@ -230,7 +230,7 @@ bool WFSchemaSetPath(Token in_schema, CStyleString in_value);
* Please note that curly braces are required.
* @return true on success, false on failure
*/
bool WFSchemaSetClsid(Token in_schema, CStyleString in_value);
bool WFSchemaSetClsid(WFToken in_schema, WFCString in_value);
/**
* @brief Set the program name for a Schema (optional)
@@ -239,7 +239,7 @@ bool WFSchemaSetClsid(Token in_schema, CStyleString in_value);
* @param[in] in_value Null-terminated UTF-8 string containing the name, or NULL to clear
* @return true on success, false on failure
*/
bool WFSchemaSetName(Token in_schema, CStyleString in_value);
bool WFSchemaSetName(WFToken in_schema, WFCString in_value);
/**
* @brief Set the program icon for a Schema (optional)
@@ -248,7 +248,7 @@ bool WFSchemaSetName(Token in_schema, CStyleString in_value);
* @param[in] in_value Null-terminated UTF-8 string containing the icon path, or NULL to clear
* @return true on success, false on failure
*/
bool WFSchemaSetIcon(Token in_schema, CStyleString in_value);
bool WFSchemaSetIcon(WFToken in_schema, WFCString in_value);
/**
* @brief Set the program behavior for a Schema (optional)
@@ -257,7 +257,7 @@ bool WFSchemaSetIcon(Token in_schema, CStyleString in_value);
* @param[in] in_value Null-terminated UTF-8 string containing the behavior command, or NULL to clear
* @return true on success, false on failure
*/
bool WFSchemaSetBehavior(Token in_schema, CStyleString in_value);
bool WFSchemaSetBehavior(WFToken in_schema, WFCString in_value);
/**
* @brief Add a string resource entry to a Schema
@@ -268,7 +268,7 @@ bool WFSchemaSetBehavior(Token in_schema, CStyleString in_value);
* It can be a plain string or a reference string to resource.
* @return true on success, false on failure
*/
bool WFSchemaAddStr(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddStr(WFToken in_schema, WFCString in_name, WFCString in_value);
/**
* @brief Add an icon registry entry to a Schema
@@ -279,7 +279,7 @@ bool WFSchemaAddStr(Token in_schema, CStyleString in_name, CStyleString in_value
* It can be a path to icon or a reference string to resource.
* @return true on success, false on failure
*/
bool WFSchemaAddIcon(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddIcon(WFToken in_schema, WFCString in_name, WFCString in_value);
/**
* @brief Add a behavior registry entry to a Schema
@@ -290,7 +290,7 @@ bool WFSchemaAddIcon(Token in_schema, CStyleString in_name, CStyleString in_valu
* It should be a valid command line string which use \c %1, \c %2, etc. to represent parameters.
* @return true on success, false on failure
*/
bool WFSchemaAddBehavior(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddBehavior(WFToken in_schema, WFCString in_name, WFCString in_value);
/**
* @brief Add a file extension to a Schema
@@ -305,11 +305,11 @@ bool WFSchemaAddBehavior(Token in_schema, CStyleString in_name, CStyleString in_
* This name should be registered by calling WFSchemaAddBehavior().
* @return true on success, false on failure
*/
bool WFSchemaAddExt(Token in_schema,
CStyleString in_ext,
CStyleString in_ext_name,
CStyleString in_ext_icon,
CStyleString in_ext_behavior);
bool WFSchemaAddExt(WFToken in_schema,
WFCString in_ext,
WFCString in_ext_name,
WFCString in_ext_icon,
WFCString in_ext_behavior);
/**
* @brief Create a Program object from a Schema
@@ -327,7 +327,7 @@ bool WFSchemaAddExt(Token in_schema,
* And it should be freed by calling WFProgramDestroy() when it is no longer needed.
* @return true on success, false on failure
*/
bool WFProgramCreate(Token in_schema, Token *out_program);
bool WFProgramCreate(WFToken in_schema, WFToken *out_program);
/**
* @brief Destroy a Program object
@@ -337,7 +337,7 @@ bool WFProgramCreate(Token in_schema, Token *out_program);
* @param[in] in_program Program token to destroy
* @return true on success, false on failure
*/
bool WFProgramDestroy(Token in_program);
bool WFProgramDestroy(WFToken in_program);
/**
* @brief Resolve the provided program name of this Program
@@ -352,7 +352,7 @@ bool WFProgramDestroy(Token in_program);
* This string will be freed at the next API call. Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFProgramResolveName(Token in_program, CStyleString *out_name);
bool WFProgramResolveName(WFToken in_program, WFCString *out_name);
/**
* @brief Resolve the Program icon resource
@@ -367,7 +367,7 @@ bool WFProgramResolveName(Token in_program, CStyleString *out_name);
* And it should be freed by calling WFIconRcDestroy() when it is no longer needed.
* @return true on success, false on failure
*/
bool WFProgramResolveIcon(Token in_program, Token *out_icon_rc);
bool WFProgramResolveIcon(WFToken in_program, WFToken *out_icon_rc);
/**
* @brief Get the number of file extensions in the Program
@@ -376,17 +376,17 @@ bool WFProgramResolveIcon(Token in_program, Token *out_icon_rc);
* @param[out] out_len Pointer to receive the number of extensions
* @return true on success, false on failure
*/
bool WFProgramExtsLen(Token in_program, size_t *out_len);
bool WFProgramExtsLen(WFToken in_program, size_t *out_len);
/**
* @brief Find a file extension by its body (extension string)
*
* @param[in] in_program Program token
* @param[in] in_body Null-terminated UTF-8 string containing the file extension name (without leading dot) to find.
* @param[out] out_index Pointer to receive the file extension index, or INVALID_INDEX if not found.
* @param[out] out_index Pointer to receive the file extension index, or WF_INVALID_INDEX if not found.
* @return true on success, false on failure
*/
bool WFProgramFindExt(Token in_program, CStyleString in_body, size_t *out_index);
bool WFProgramFindExt(WFToken in_program, WFCString in_body, size_t *out_index);
/**
* @brief Resolve this program provided extension's details by index
@@ -398,7 +398,7 @@ bool WFProgramFindExt(Token in_program, CStyleString in_body, size_t *out_index)
* And it should be freed by calling WFSelfExtStatusDestroy() when it is no longer needed.
* @return true on success, false on failure
*/
bool WFProgramResolveExt(Token in_program, size_t in_index, Token *out_self_ext_status);
bool WFProgramResolveExt(WFToken in_program, size_t in_index, WFToken *out_self_ext_status);
/**
* @brief Register the Program in the specified scope
@@ -407,7 +407,7 @@ bool WFProgramResolveExt(Token in_program, size_t in_index, Token *out_self_ext_
* @param[in] in_scope Registration scope
* @return true on success, false on failure
*/
bool WFProgramRegister(Token in_program, Scope in_scope);
bool WFProgramRegister(WFToken in_program, WFScope in_scope);
/**
* @brief Unregister the Program from the specified scope
@@ -416,7 +416,7 @@ bool WFProgramRegister(Token in_program, Scope in_scope);
* @param[in] in_scope Registration scope
* @return true on success, false on failure
*/
bool WFProgramUnregister(Token in_program, Scope in_scope);
bool WFProgramUnregister(WFToken in_program, WFScope in_scope);
/**
* @brief Check if the Program is registered in the specified scope
@@ -427,7 +427,7 @@ bool WFProgramUnregister(Token in_program, Scope in_scope);
* True if the Program is registered in the specified scope, false otherwise.
* @return true on success, false on failure
*/
bool WFProgramIsRegistered(Token in_program, Scope in_scope, bool *out_is_registered);
bool WFProgramIsRegistered(WFToken in_program, WFScope in_scope, bool *out_is_registered);
/**
* @brief Link a file extension in the specified scope
@@ -437,7 +437,7 @@ bool WFProgramIsRegistered(Token in_program, Scope in_scope, bool *out_is_regist
* @param[in] in_index Index of the extension to link
* @return true on success, false on failure
*/
bool WFProgramLinkExt(Token in_program, Scope in_scope, size_t in_index);
bool WFProgramLinkExt(WFToken in_program, WFScope in_scope, size_t in_index);
/**
* @brief Unlink a file extension in the specified scope
@@ -447,7 +447,7 @@ bool WFProgramLinkExt(Token in_program, Scope in_scope, size_t in_index);
* @param[in] in_index Index of the extension to unlink
* @return true on success, false on failure
*/
bool WFProgramUnlinkExt(Token in_program, Scope in_scope, size_t in_index);
bool WFProgramUnlinkExt(WFToken in_program, WFScope in_scope, size_t in_index);
/**
* @brief Query the status of a file extension
@@ -461,7 +461,7 @@ bool WFProgramUnlinkExt(Token in_program, Scope in_scope, size_t in_index);
* And it should be freed by calling WFExtStatusDestroy() when it is no longer needed.
* @return true on success, false on failure
*/
bool WFProgramQueryExt(Token in_program, View in_view, size_t in_index, Token *out_ext_status);
bool WFProgramQueryExt(WFToken in_program, WFView in_view, size_t in_index, WFToken *out_ext_status);
/**
* @brief Destroy an extension status object
@@ -469,7 +469,7 @@ bool WFProgramQueryExt(Token in_program, View in_view, size_t in_index, Token *o
* @param[in] in_ext_status Extension status token to destroy
* @return true on success, false on failure
*/
bool WFExtStatusDestroy(Token in_ext_status);
bool WFExtStatusDestroy(WFToken in_ext_status);
/**
* @brief Get the display name from an extension status object
@@ -484,7 +484,7 @@ bool WFExtStatusDestroy(Token in_ext_status);
* This string will be freed at the next API call. Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFExtStatusGetName(Token in_ext_status, CStyleString *out_name);
bool WFExtStatusGetName(WFToken in_ext_status, WFCString *out_name);
/**
* @brief Get the icon from an extension status object
@@ -498,7 +498,7 @@ bool WFExtStatusGetName(Token in_ext_status, CStyleString *out_name);
* Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFExtStatusGetIcon(Token in_ext_status, HICON *out_icon);
bool WFExtStatusGetIcon(WFToken in_ext_status, WFHICON *out_icon);
/**
* @brief Destroy a self extension status object
@@ -506,7 +506,7 @@ bool WFExtStatusGetIcon(Token in_ext_status, HICON *out_icon);
* @param[in] in_self_ext_status Self extension status token to destroy
* @return true on success, false on failure
*/
bool WFSelfExtStatusDestroy(Token in_self_ext_status);
bool WFSelfExtStatusDestroy(WFToken in_self_ext_status);
/**
* @brief Get the display name from a self extension status object
@@ -520,7 +520,7 @@ bool WFSelfExtStatusDestroy(Token in_self_ext_status);
* This string will be freed at the next API call. Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFSelfExtStatusGetName(Token in_self_ext_status, CStyleString *out_name);
bool WFSelfExtStatusGetName(WFToken in_self_ext_status, WFCString *out_name);
/**
* @brief Get the icon from a self extension status object
@@ -534,7 +534,7 @@ bool WFSelfExtStatusGetName(Token in_self_ext_status, CStyleString *out_name);
* Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFSelfExtStatusGetIcon(Token in_self_ext_status, HICON *out_icon);
bool WFSelfExtStatusGetIcon(WFToken in_self_ext_status, WFHICON *out_icon);
/**
* @brief Get the extension string (without leading dot) from a self extension status object
@@ -545,7 +545,7 @@ bool WFSelfExtStatusGetIcon(Token in_self_ext_status, HICON *out_icon);
* This string will be freed at the next API call. Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFSelfExtStatusGetExt(Token in_self_ext_status, CStyleString *out_inner);
bool WFSelfExtStatusGetExt(WFToken in_self_ext_status, WFCString *out_inner);
/**
* @brief Get the dotted extension string (with leading dot) from a self extension status object
@@ -556,7 +556,7 @@ bool WFSelfExtStatusGetExt(Token in_self_ext_status, CStyleString *out_inner);
* This string will be freed at the next API call. Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFSelfExtStatusGetDottedExt(Token in_self_ext_status, CStyleString *out_inner);
bool WFSelfExtStatusGetDottedExt(WFToken in_self_ext_status, WFCString *out_inner);
/**
* @brief Destroy an icon resource object
@@ -564,19 +564,19 @@ bool WFSelfExtStatusGetDottedExt(Token in_self_ext_status, CStyleString *out_inn
* @param[in] in_icon_rc Icon resource token to destroy
* @return true on success, false on failure
*/
bool WFIconRcDestroy(Token in_icon_rc);
bool WFIconRcDestroy(WFToken in_icon_rc);
/**
* @brief Get the icon handle from an icon resource object
*
* @param[in] in_icon_rc Icon resource token
* @param[out] out_icon Pointer to receive the icon handle.
* There is no possibility that this value is INVALID_HICON.
* There is no possibility that this value is WF_INVALID_HICON.
* This icon handle will be freed once this icon resource object is destroyed.
* Please make a copy immediately if you need to use it longer.
* @return true on success, false on failure
*/
bool WFIconRcGetIcon(Token in_icon_rc, HICON *out_icon);
bool WFIconRcGetIcon(WFToken in_icon_rc, WFHICON *out_icon);
#ifdef __cplusplus
} // extern "C"