This document summarizes the public macros provided by obfy and shows short usage examples.
OBFY_STR,OBFY_WSTROBFY_STR_ONCE,OBFY_WSTR_ONCE
const char* msg = OBFY_STR("secret");
const wchar_t* wmsg = OBFY_WSTR(L"wide");
auto tmp = OBFY_STR_ONCE("one-shot");
auto wtmp = OBFY_WSTR_ONCE(L"w-one-shot");These macros accept only string literals whose character type matches the macro.
Using a wide literal with OBFY_STR or a narrow literal with OBFY_WSTR
results in a compilation error.
*_ONCE macros return a temporary that zeroes its storage on destruction. Pointers from c_str() remain valid only within the full expression; copy the string if a longer lifetime is required.
OBFY_BYTESOBFY_BYTES_ONCE
Requires including obfy_bytes.hpp.
const unsigned char* key = OBFY_BYTES("\x01\x02\x03\x04");
auto tmp_block = OBFY_BYTES_ONCE("\xAA\xBB");OBFY_BYTES_ONCE behaves similarly, returning a temporary block that clears its contents when destroyed.
Requires including obfy_call.hpp. Define OBFY_ENABLE_FSM_CALL to enable the state-machine wrapper.
OBFY_CALLOBFY_CALL_RET
int r = OBFY_CALL_RET(int, add, 1, 2);
OBFY_CALL(do_work);OBFY_V,OBFY_NOBFY_RATIO_D,OBFY_RATIO_FOBFY_BIT_CAST
OBFY_V(x) = 42;
int n = OBFY_N(10);
double pi = OBFY_RATIO_D(314, 100);
float f = OBFY_RATIO_F(22, 7);
auto bits = OBFY_BIT_CAST<unsigned>(0.5f);OBFY_BEGIN_CODE/OBFY_END_CODEOBFY_IF/OBFY_ELSE/OBFY_ENDIFOBFY_FOR/OBFY_ENDFOR,OBFY_WHILE/OBFY_ENDWHILEOBFY_REPEAT/OBFY_AS_LONG_ASOBFY_CASE/OBFY_WHEN/OBFY_DO/OBFY_DONE/OBFY_OR/OBFY_DEFAULT/OBFY_ENDCASEOBFY_RETURN,OBFY_BREAK,OBFY_CONTINUE
OBFY_BEGIN_CODE
OBFY_IF(check())
OBFY_RETURN(42);
OBFY_ELSE
OBFY_FOR(int i = 0; i < 3; ++i)
OBFY_CONTINUE;
OBFY_ENDFOR
OBFY_ENDIF
OBFY_CASE(n)
OBFY_WHEN(1) OBFY_OR(2) OBFY_DO { OBFY_BREAK; } OBFY_DONE
OBFY_DEFAULT OBFY_DO { OBFY_BREAK; } OBFY_DONE
OBFY_ENDCASE
OBFY_END_CODE