1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_FILTERFW_CORE_VALUE_H 18#define ANDROID_FILTERFW_CORE_VALUE_H 19 20#ifdef __cplusplus 21extern "C" { 22#endif 23 24// TODO: As this is no longer part of the proposed NDK, should we make this object-oriented (C++) 25// instead? We can also probably clean this up a bit. 26 27// TODO: Change this to an opaque handle? 28typedef struct { 29 void* value; 30 int type; 31 int count; 32} Value; 33 34// TODO: Probably should make these const Value*? 35int GetIntValue(Value value); 36float GetFloatValue(Value value); 37const char* GetStringValue(Value value); 38const char* GetBufferValue(Value value); 39char* GetMutableBufferValue(Value value); 40int* GetIntArrayValue(Value value); 41float* GetFloatArrayValue(Value value); 42 43// TODO: Probably should make these const Value*? 44int ValueIsNull(Value value); 45int ValueIsInt(Value value); 46int ValueIsFloat(Value value); 47int ValueIsString(Value value); 48int ValueIsBuffer(Value value); 49int ValueIsMutableBuffer(Value value); 50int ValueIsIntArray(Value value); 51int ValueIsFloatArray(Value value); 52 53Value MakeNullValue(); 54Value MakeIntValue(int value); 55Value MakeFloatValue(float value); 56Value MakeStringValue(const char* value); 57Value MakeBufferValue(const char* data, int size); 58Value MakeBufferValueNoCopy(const char* data, int size); 59Value MakeMutableBufferValue(const char* data, int size); 60Value MakeMutableBufferValueNoCopy(char* data, int size); 61Value MakeIntArrayValue(const int* values, int count); 62Value MakeFloatArrayValue(const float* values, int count); 63 64// Note: These only alloc if value is Null! Otherwise they overwrite, so data must fit! 65int SetIntValue(Value* value, int new_value); 66int SetFloatValue(Value* value, float new_value); 67int SetStringValue(Value* value, const char* new_value); 68int SetMutableBufferValue(Value* value, const char* new_data, int size); 69int SetIntArrayValue(Value* value, const int* new_values, int count); 70int SetFloatArrayValue(Value* value, const float* new_values, int count); 71 72int GetValueCount(Value value); 73 74void ReleaseValue(Value* value); 75 76#ifdef __cplusplus 77} // extern "C" 78#endif 79 80#endif // ANDROID_FILTERFW_FILTER_VALUE_H 81