• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21  extern "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?
28  typedef struct {
29    void* value;
30    int type;
31    int count;
32  } Value;
33  
34  // TODO: Probably should make these const Value*?
35  int GetIntValue(Value value);
36  float GetFloatValue(Value value);
37  const char* GetStringValue(Value value);
38  const char* GetBufferValue(Value value);
39  char* GetMutableBufferValue(Value value);
40  int* GetIntArrayValue(Value value);
41  float* GetFloatArrayValue(Value value);
42  
43  // TODO: Probably should make these const Value*?
44  int ValueIsNull(Value value);
45  int ValueIsInt(Value value);
46  int ValueIsFloat(Value value);
47  int ValueIsString(Value value);
48  int ValueIsBuffer(Value value);
49  int ValueIsMutableBuffer(Value value);
50  int ValueIsIntArray(Value value);
51  int ValueIsFloatArray(Value value);
52  
53  Value MakeNullValue();
54  Value MakeIntValue(int value);
55  Value MakeFloatValue(float value);
56  Value MakeStringValue(const char* value);
57  Value MakeBufferValue(const char* data, int size);
58  Value MakeBufferValueNoCopy(const char* data, int size);
59  Value MakeMutableBufferValue(const char* data, int size);
60  Value MakeMutableBufferValueNoCopy(char* data, int size);
61  Value MakeIntArrayValue(const int* values, int count);
62  Value MakeFloatArrayValue(const float* values, int count);
63  
64  // Note: These only alloc if value is Null! Otherwise they overwrite, so data must fit!
65  int SetIntValue(Value* value, int new_value);
66  int SetFloatValue(Value* value, float new_value);
67  int SetStringValue(Value* value, const char* new_value);
68  int SetMutableBufferValue(Value* value, const char* new_data, int size);
69  int SetIntArrayValue(Value* value, const int* new_values, int count);
70  int SetFloatArrayValue(Value* value, const float* new_values, int count);
71  
72  int GetValueCount(Value value);
73  
74  void ReleaseValue(Value* value);
75  
76  #ifdef __cplusplus
77  } // extern "C"
78  #endif
79  
80  #endif  // ANDROID_FILTERFW_FILTER_VALUE_H
81