2022-11-03 13:12:45 -04:00
|
|
|
#ifndef INFLUXDB_H
|
|
|
|
#define INFLUXDB_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <iostream>
|
2022-11-03 16:31:33 -04:00
|
|
|
#include <vector>
|
2022-11-03 13:12:45 -04:00
|
|
|
#include <string>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
class InfluxDB{
|
|
|
|
private:
|
|
|
|
|
|
|
|
CURL * curl;
|
|
|
|
CURLcode respond;
|
|
|
|
long respondCode;
|
|
|
|
|
|
|
|
std::string databaseIP;
|
|
|
|
std::string dataPoints;
|
|
|
|
|
2022-11-03 16:31:33 -04:00
|
|
|
std::vector<std::string> databaseList;
|
|
|
|
|
2022-11-03 13:12:45 -04:00
|
|
|
static size_t WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp);
|
|
|
|
|
|
|
|
void Execute();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// url = https://fsunuc.physics.fsu.edu/InfluxDB/
|
|
|
|
InfluxDB(std::string url, bool verbose = false);
|
|
|
|
~InfluxDB();
|
2022-11-03 16:31:33 -04:00
|
|
|
|
|
|
|
void SetURL(std::string url);
|
2022-11-03 13:12:45 -04:00
|
|
|
|
|
|
|
/// Query
|
2022-11-03 16:31:33 -04:00
|
|
|
std::string ShowDatabases(); /// this save the list of database into databaseList
|
2022-11-03 13:12:45 -04:00
|
|
|
std::string Query(std::string databaseName, std::string query);
|
|
|
|
|
2022-11-03 16:31:33 -04:00
|
|
|
/// the ShowDatabases() function must be called before
|
|
|
|
std::vector<std::string> GetDatabaseList() {return databaseList;}
|
|
|
|
|
2022-11-03 13:12:45 -04:00
|
|
|
void CreateDatabase(std::string databaseName);
|
|
|
|
|
|
|
|
/// for single or batch write,
|
|
|
|
/// 1, addDataPoint first, you can add as many as you like
|
|
|
|
/// 2, writeData.
|
|
|
|
void AddDataPoint(std::string fullString);
|
2022-11-03 16:31:33 -04:00
|
|
|
void ClearDataPointsBuffer();
|
2022-11-03 13:12:45 -04:00
|
|
|
void PrintDataPoints();
|
|
|
|
void WriteData(std::string databaseName);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|