All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_util.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 
18 #pragma once
19 
20 #include <stddef.h>
21 
22 #include <citrusleaf/alloc.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /******************************************************************************
29  * MACROS
30  ******************************************************************************/
31 
32 /**
33  * Calls a hook on a object.
34  * If hook not found, then return the default value.
35  */
36 #define as_util_hook(hook,default,object,args...) \
37  (object && object->hooks && object->hooks->hook ? object->hooks->hook(object, ## args) : default)
38 
39 /**
40  * Converts from an as_val.
41  */
42 #define as_util_fromval(object,type_id,type) \
43  (object && as_val_type(object) == type_id ? (type *) object : NULL)
44 
45 #ifdef __cplusplus
46 } // end extern "C"
47 #endif