OCBoolean
- group OCBoolean
Immutable Boolean type abstraction in OCTypes.
Functions
-
OCTypeID OCBooleanGetTypeID(void)
Returns the unique type identifier for the OCBoolean class.
- Returns:
The OCTypeID associated with OCBoolean objects. This ID distinguishes OCBoolean from other OCType-compatible types.
-
bool OCBooleanGetValue(OCBooleanRef boolean)
Retrieves the primitive Boolean value (
trueorfalse) from an OCBooleanRef.- Parameters:
boolean – The OCBooleanRef to query. Must be either kOCBooleanTrue or kOCBooleanFalse.
- Returns:
trueifbooleanis kOCBooleanTrue;falseif it is kOCBooleanFalse. Behavior is undefined for invalid or uninitialized values.
-
OCBooleanRef OCBooleanGetWithBool(bool value)
Return the OCBoolean singleton corresponding to the given C bool. No ownership is transferred.
- Parameters:
value – A C bool.
- Returns:
kOCBooleanTrue if value is true, else kOCBooleanFalse.
-
OCStringRef OCBooleanCreateStringValue(OCBooleanRef boolean)
Returns a new OCStringRef representing the Boolean value (“true” or “false”).
- Parameters:
boolean – The OCBooleanRef to convert.
- Returns:
A new OCStringRef (“true” or “false”). Caller must release.
-
cJSON *OCBooleanCopyAsJSON(OCBooleanRef boolean, bool typed, OCStringRef *outError)
Creates a JSON representation of an OCBooleanRef.
Since booleans are native JSON types, both typed and untyped serialization produce the same result: a JSON boolean (true or false).
- Parameters:
boolean – A valid OCBooleanRef (kOCBooleanTrue or kOCBooleanFalse).
typed – Whether to include type information (ignored for booleans).
outError – Optional pointer to receive an error string on failure.
- Returns:
A new cJSON boolean node, or cJSON null if input is NULL. Caller is responsible for managing the returned cJSON object.
-
OCBooleanRef OCBooleanCreateFromJSON(cJSON *json, OCStringRef *outError)
Creates an OCBooleanRef from a JSON boolean node.
This function maps JSON true to
kOCBooleanTrueand false tokOCBooleanFalse.- Parameters:
json – A cJSON boolean node.
json – A cJSON node expected to be a boolean.
outError – Optional pointer to receive an error string on failure.
- Returns:
kOCBooleanTrueorkOCBooleanFalse, or NULL if input is invalid. Returned object is a singleton and must not be released.
Variables
-
const OCBooleanRef kOCBooleanTrue
The immutable singleton OCBooleanRef representing Boolean true.
Use this whenever a true Boolean value is required in the OCType system. Do not manually allocate or deallocate this object.
-
const OCBooleanRef kOCBooleanFalse
The immutable singleton OCBooleanRef representing Boolean false.
Use this whenever a false Boolean value is required in the OCType system. Do not manually allocate or deallocate this object.
-
OCTypeID OCBooleanGetTypeID(void)