|
108 | 108 | } \ |
109 | 109 | } while (false) |
110 | 110 |
|
111 | | -/** |
112 | | - * Verifies that a valid Pubnub user ID has been set before continuing. |
113 | | - * |
114 | | - * If the user ID is not set, this macro will: |
115 | | - * - Log an error message to the output log |
116 | | - * - Invoke the provided delegate with a failure result and optional additional arguments |
117 | | - * - Immediately return from the calling function |
118 | | - */ |
119 | | -#define PUBNUB_ENSURE_USER_ID_IS_SET(Delegate, ...) \ |
120 | | - do { \ |
121 | | - if (!IsUserIDSet) \ |
122 | | - { \ |
123 | | - PubnubError(FString::Printf(TEXT("[%s]: Pubnub user ID is not set. Aborting operation."), *UPubnubUtilities::GetNameFromFunctionMacro(ANSI_TO_TCHAR(__FUNCTION__)))); \ |
124 | | - UPubnubUtilities::CallPubnubDelegateWithInvalidArgumentResult(Delegate, TEXT("Pubnub user ID is not set."), ##__VA_ARGS__); \ |
125 | | - return; \ |
126 | | - } \ |
127 | | - } while (false) |
128 | | - |
129 | 111 | /** |
130 | 112 | * Verifies that a valid Pubnub user ID has been set before continuing. |
131 | 113 | * |
|
143 | 125 | } \ |
144 | 126 | } while (false) |
145 | 127 |
|
146 | | -/** |
147 | | - * Verifies that provided condition is met. |
148 | | - * |
149 | | - * If the condition is not met, this macro will: |
150 | | - * - Log an error message to the output log |
151 | | - * - Invoke the provided delegate with a failure result and optional additional arguments |
152 | | - * - Immediately return from the calling function |
153 | | - */ |
154 | | -#define PUBNUB_ENSURE_CONDITION(Condition, ErrorMessage, Delegate, ...) \ |
155 | | - do { \ |
156 | | - if (!(Condition)) \ |
157 | | - { \ |
158 | | - PubnubError(FString::Printf(TEXT("[%s]: %s Aborting operation."), *UPubnubUtilities::GetNameFromFunctionMacro(ANSI_TO_TCHAR(__FUNCTION__)), ErrorMessage)); \ |
159 | | - UPubnubUtilities::CallPubnubDelegateWithInvalidArgumentResult(Delegate, ErrorMessage, ##__VA_ARGS__); \ |
160 | | - return; \ |
161 | | - } \ |
162 | | - } while (false) |
163 | | - |
164 | 128 | /** |
165 | 129 | * Verifies that the provided condition is met before continuing. |
166 | 130 | * |
|
420 | 384 | } \ |
421 | 385 | } while (false) |
422 | 386 |
|
423 | | -/** |
424 | | - * Validates that the provided field (e.g., channel name, message, metadata) is not empty. |
425 | | - * |
426 | | - * If the field is empty, this macro will: |
427 | | - * - Log a warning message indicating the missing field |
428 | | - * - Call the specified delegate with a failure result including the field name in the error message |
429 | | - * - Immediately return from the calling function |
430 | | - * |
431 | | - * Usage: Use to guard against invalid or missing user input before executing core logic. |
432 | | - * |
433 | | - * @param Field The field to validate (must implement IsEmpty()) |
434 | | - * @param Delegate The delegate to call on failure |
435 | | - * @param ... Additional arguments to pass to the delegate (after the result) |
436 | | - */ |
437 | | -#define PUBNUB_ENSURE_FIELD_NOT_EMPTY(Field, Delegate, ...) \ |
438 | | - do { \ |
439 | | - if (Field.IsEmpty()) \ |
440 | | - { \ |
441 | | - PubnubError(FString::Printf(TEXT("[%s]: %s field can't be empty. Aborting operation."), *UPubnubUtilities::GetNameFromFunctionMacro(ANSI_TO_TCHAR(__FUNCTION__)), TEXT(#Field)), EPubnubErrorType::PET_Warning); \ |
442 | | - UPubnubUtilities::CallPubnubDelegateWithInvalidArgumentResult(Delegate, FString::Printf(TEXT("Missing required input: '%s' (field is empty). Operation aborted."), TEXT(#Field)), ##__VA_ARGS__); \ |
443 | | - return; \ |
444 | | - } \ |
445 | | - } while (false) |
446 | 387 |
|
447 | 388 | /** |
448 | 389 | * Validates that the provided field (e.g., channel name, message, metadata) is not empty. |
|
0 commit comments