Zen API
 All Classes Files Functions Variables Typedefs Macros Groups Pages
kValue.h
Go to the documentation of this file.
1 /**
2  * @file kValue.h
3  * @brief Declares the kValue type.
4  *
5  * @internal
6  * Copyright (C) 2012-2014 by LMI Technologies Inc.
7  * Licensed under the MIT License.
8  * Redistributed files must retain the above copyright notice.
9  */
10 #include <kApi/kApiDef.h> //--inclusion order controlled by kApiDef
11 
12 #ifndef K_API_VALUE_H
13 #define K_API_VALUE_H
14 
15 kBeginHeader()
16 
17 /**
18  * @class kValue
19  * @ingroup kApi
20  * @brief Root of all value types in the kType system.
21  *
22  * Value types represent structures, enumerations, and primitive values. The kValue base type defines
23  * methods that can be called on any value instance.
24  */
25 
26 /**
27  * Determines whether a value is equal to another value.
28  *
29  * The default implementation of this method uses type reflection to compare the values field by field.
30  * This approach is not efficient, and in some cases may not produce the desired result. Value types should
31  * override this method if it is likely that equality comparisons will be required.
32  *
33  * @public @memberof kValue
34  * @param type Value type.
35  * @param value Pointer to value.
36  * @param other Pointer to other value.
37  * @return kTRUE if the values are equal.
38  */
39 kFx(kBool) kValue_Equals(kType type, const void* value, const void* other);
40 
41 /**
42  * Gets a hash code representing the state of this value.
43  *
44  * The default implementation of this method uses type reflection to generate a hash code that combines the
45  * hash codes from individual fields. This approach is not efficient, and may not produce an optimal hash code.
46  * Value types should override this method if it is likely that hash codes will be required.
47  *
48  * @public @memberof kValue
49  * @param type Value type.
50  * @param value Pointer to value.
51  * @return Hash code.
52  */
53 kFx(kSize) kValue_HashCode(kType type, const void* value);
54 
55 /**
56  * Imports the content of another value into this value.
57  *
58  * This method supports importing content from an external source, which may have a different size.
59  * In particular, "array value" types such as kText32 can import from a null-terminated source array of a differnt
60  * length.
61  *
62  * @public @memberof kValue
63  * @param type Value type.
64  * @param value Pointer to value.
65  * @param source Source for import.
66  */
67 kFx(void) kValue_Import(kType type, void* value, const void* source);
68 
69 kEndHeader()
70 
71 #include <kApi/kValue.x.h>
72 
73 #endif
kBool kValue_Equals(kType type, const void *value, const void *other)
Determines whether a value is equal to another value.
Represents an unsigned integer that can store a pointer address.
void kValue_Import(kType type, void *value, const void *source)
Imports the content of another value into this value.
Essential API declarations.
Represents metadata about a type (class, interface, or value).
Represents a boolean value.
kSize kValue_HashCode(kType type, const void *value)
Gets a hash code representing the state of this value.