1/* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11/* 12 * This is the pure C wrapper of the DataLog class. 13 */ 14 15#include "system_wrappers/interface/data_log_c.h" 16 17#include <string> 18 19#include "system_wrappers/interface/data_log.h" 20 21extern "C" int WebRtcDataLog_CreateLog() { 22 return webrtc::DataLog::CreateLog(); 23} 24 25extern "C" void WebRtcDataLog_ReturnLog() { 26 return webrtc::DataLog::ReturnLog(); 27} 28 29extern "C" char* WebRtcDataLog_Combine(char* combined_name, size_t combined_len, 30 const char* table_name, int table_id) { 31 if (!table_name) return NULL; 32 std::string combined = webrtc::DataLog::Combine(table_name, table_id); 33 if (combined.size() >= combined_len) return NULL; 34 std::copy(combined.begin(), combined.end(), combined_name); 35 combined_name[combined.size()] = '\0'; 36 return combined_name; 37} 38 39extern "C" int WebRtcDataLog_AddTable(const char* table_name) { 40 if (!table_name) return -1; 41 return webrtc::DataLog::AddTable(table_name); 42} 43 44extern "C" int WebRtcDataLog_AddColumn(const char* table_name, 45 const char* column_name, 46 int multi_value_length) { 47 if (!table_name || !column_name) return -1; 48 return webrtc::DataLog::AddColumn(table_name, column_name, 49 multi_value_length); 50} 51 52extern "C" int WebRtcDataLog_InsertCell_int(const char* table_name, 53 const char* column_name, 54 int value) { 55 if (!table_name || !column_name) return -1; 56 return webrtc::DataLog::InsertCell(table_name, column_name, value); 57} 58 59extern "C" int WebRtcDataLog_InsertArray_int(const char* table_name, 60 const char* column_name, 61 const int* values, 62 int length) { 63 if (!table_name || !column_name) return -1; 64 return webrtc::DataLog::InsertCell(table_name, column_name, values, length); 65} 66 67extern "C" int WebRtcDataLog_InsertCell_float(const char* table_name, 68 const char* column_name, 69 float value) { 70 if (!table_name || !column_name) return -1; 71 return webrtc::DataLog::InsertCell(table_name, column_name, value); 72} 73 74extern "C" int WebRtcDataLog_InsertArray_float(const char* table_name, 75 const char* column_name, 76 const float* values, 77 int length) { 78 if (!table_name || !column_name) return -1; 79 return webrtc::DataLog::InsertCell(table_name, column_name, values, length); 80} 81 82extern "C" int WebRtcDataLog_InsertCell_double(const char* table_name, 83 const char* column_name, 84 double value) { 85 if (!table_name || !column_name) return -1; 86 return webrtc::DataLog::InsertCell(table_name, column_name, value); 87} 88 89extern "C" int WebRtcDataLog_InsertArray_double(const char* table_name, 90 const char* column_name, 91 const double* values, 92 int length) { 93 if (!table_name || !column_name) return -1; 94 return webrtc::DataLog::InsertCell(table_name, column_name, values, length); 95} 96 97extern "C" int WebRtcDataLog_InsertCell_int32(const char* table_name, 98 const char* column_name, 99 int32_t value) { 100 if (!table_name || !column_name) return -1; 101 return webrtc::DataLog::InsertCell(table_name, column_name, value); 102} 103 104extern "C" int WebRtcDataLog_InsertArray_int32(const char* table_name, 105 const char* column_name, 106 const int32_t* values, 107 int length) { 108 if (!table_name || !column_name) return -1; 109 return webrtc::DataLog::InsertCell(table_name, column_name, values, length); 110} 111 112extern "C" int WebRtcDataLog_InsertCell_uint32(const char* table_name, 113 const char* column_name, 114 uint32_t value) { 115 if (!table_name || !column_name) return -1; 116 return webrtc::DataLog::InsertCell(table_name, column_name, value); 117} 118 119extern "C" int WebRtcDataLog_InsertArray_uint32(const char* table_name, 120 const char* column_name, 121 const uint32_t* values, 122 int length) { 123 if (!table_name || !column_name) return -1; 124 return webrtc::DataLog::InsertCell(table_name, column_name, values, length); 125} 126 127extern "C" int WebRtcDataLog_InsertCell_int64(const char* table_name, 128 const char* column_name, 129 int64_t value) { 130 if (!table_name || !column_name) return -1; 131 return webrtc::DataLog::InsertCell(table_name, column_name, value); 132} 133 134extern "C" int WebRtcDataLog_InsertArray_int64(const char* table_name, 135 const char* column_name, 136 const int64_t* values, 137 int length) { 138 if (!table_name || !column_name) return -1; 139 return webrtc::DataLog::InsertCell(table_name, column_name, values, length); 140} 141 142extern "C" int WebRtcDataLog_NextRow(const char* table_name) { 143 if (!table_name) return -1; 144 return webrtc::DataLog::NextRow(table_name); 145} 146