[ENROLLEE] Tizen enrollee sample application build using scons command
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / android / jni / jniutil / inc / jni_getter.h
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 /**
22  * @file   jni_getter.h
23  *
24  * @brief  This file contains the JGetter class  declarations and its functions required
25  *            for getting and setting basic data types in C++ and Java
26  */
27
28 #ifndef __JNI_GETTER_H_
29 #define __JNI_GETTER_H_
30
31 #include <string>
32 #include <jni.h>
33
34 /**
35  * @class   JGetter
36  * @brief  This class provide utility for get/set basic data types in C++ and Java
37  *
38  */
39 class JGetter {
40 public:
41         /**
42          * This function is called to get String field from the C++ object
43          *
44          * @param env
45          *           JNI Environment reference
46          * @param object
47          *           JObject from which string field is expected
48          * @param fieldName
49          *           Name of the field to be extracted from JObject
50          * @param value
51          *         reference to string value mentioned in fieldName
52          *
53          * @return returns true on success and false on failer.
54          */
55         static bool getJStringField(JNIEnv *env, jobject &object,
56                         const char *fieldName, std::string &value);
57
58         /**
59          * This function is called to get Boolean field from the C++ object
60          *
61          * @param env
62          *           JNI Environment reference
63          * @param object
64          *           JObject from which boolean field is expected
65          * @param fieldName
66          *           Name of the field to be extracted from JObject
67          * @param value
68          *         reference to boolean value mentioned in fieldName
69          *
70          * @return returns true on success and false on failer.
71          */
72         static bool getJBoolField(JNIEnv *env, jobject &object,
73                         const char *fieldName, bool &value);
74
75         /**
76          * This function is called to get Integer field from the C++ object
77          *
78          * @param env
79          *           JNI Environment reference
80          * @param object
81          *           JObject from which integer field is expected
82          * @param fieldName
83          *           Name of the field to be extracted from JObject
84          * @param value
85          *         reference to integer value mentioned in fieldName
86          *
87          * @return returns true on success and false on failer.
88          */
89         static bool getJIntField(JNIEnv *env, jobject &object,
90                         const char *fieldName, int &value);
91
92         /**
93          * This function is called to get Object reference from the C++ object
94          *
95          * @param env
96          *           JNI Environment reference
97          * @param object
98          *           JObject from which Object reference is expected
99          * @param fieldName
100          *           Name of the field to be extracted from JObject
101          * @param fieldType
102          *           Type of the field to be extracted from JObject
103          * @param value
104          *         reference to Object reference mentioned in fieldName
105          *
106          * @return returns true on success and false on failer.
107          */
108         static bool getJObjectField(JNIEnv *env, jobject &object,
109                         const char *fieldName, const char *fieldType, jobject &value);
110 };
111 #endif //__JNI_GETTER_H_