Skip to content

Commit 996f0c9

Browse files
authored
Merge pull request #181 from tobiasschuerg/fix/string_ref
fix: add strings by ref also for constructors and params
2 parents ea44e5d + 2f5eef5 commit 996f0c9

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/InfluxDbClient.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ InfluxDBClient::InfluxDBClient() {
5555
resetBuffer();
5656
}
5757

58-
InfluxDBClient::InfluxDBClient(const char *serverUrl, const char *db):InfluxDBClient() {
58+
InfluxDBClient::InfluxDBClient(const String &serverUrl, const String &db):InfluxDBClient() {
5959
setConnectionParamsV1(serverUrl, db);
6060
}
6161

62-
InfluxDBClient::InfluxDBClient(const char *serverUrl, const char *org, const char *bucket, const char *authToken):InfluxDBClient(serverUrl, org, bucket, authToken, nullptr) {
62+
InfluxDBClient::InfluxDBClient(const String &serverUrl, const String &org, const String &bucket, const String &authToken):InfluxDBClient(serverUrl, org, bucket, authToken, nullptr) {
6363
}
6464

65-
InfluxDBClient::InfluxDBClient(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *serverCert):InfluxDBClient() {
65+
InfluxDBClient::InfluxDBClient(const String &serverUrl, const String &org, const String &bucket, const String &authToken, const char *serverCert):InfluxDBClient() {
6666
setConnectionParams(serverUrl, org, bucket, authToken, serverCert);
6767
}
6868

6969
void InfluxDBClient::setInsecure(bool value){
7070
_connInfo.insecure = value;
7171
}
7272

73-
void InfluxDBClient::setConnectionParams(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo) {
73+
void InfluxDBClient::setConnectionParams(const String &serverUrl, const String &org, const String &bucket, const String &authToken, const char *certInfo) {
7474
clean();
7575
_connInfo.serverUrl = serverUrl;
7676
_connInfo.bucket = bucket;
@@ -80,7 +80,7 @@ void InfluxDBClient::setConnectionParams(const char *serverUrl, const char *org,
8080
_connInfo.dbVersion = 2;
8181
}
8282

83-
void InfluxDBClient::setConnectionParamsV1(const char *serverUrl, const char *db, const char *user, const char *password, const char *certInfo) {
83+
void InfluxDBClient::setConnectionParamsV1(const String &serverUrl, const String &db, const String &user, const String &password, const char *certInfo) {
8484
clean();
8585
_connInfo.serverUrl = serverUrl;
8686
_connInfo.bucket = db;

src/InfluxDbClient.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ class InfluxDBClient {
5757
// Creates InfluxDBClient instance for unsecured connection to InfluxDB 1
5858
// serverUrl - url of the InfluxDB 1 server (e.g. http://localhost:8086)
5959
// db - database name where to store or read data
60-
InfluxDBClient(const char *serverUrl, const char *db);
60+
InfluxDBClient(const String &serverUrl, const String &db);
6161
// Creates InfluxDBClient instance for unsecured connection
6262
// serverUrl - url of the InfluxDB 2 server (e.g. http://localhost:8086)
6363
// org - name of the organization, which bucket belongs to
6464
// bucket - name of the bucket to write data into
6565
// authToken - InfluxDB 2 authorization token
66-
InfluxDBClient(const char *serverUrl, const char *org, const char *bucket, const char *authToken);
66+
InfluxDBClient(const String &serverUrl, const String &org, const String &bucket, const String &authToken);
6767
// Creates InfluxDBClient instance for secured connection
6868
// serverUrl - url of the InfluxDB 2 server (e.g. https://localhost:8086)
6969
// org - name of the organization, which bucket belongs to
7070
// bucket - name of the bucket to write data into
7171
// authToken - InfluxDB 2 authorization token
7272
// certInfo - InfluxDB 2 server trusted certificate (or CA certificate) or certificate SHA1 fingerprint. Should be stored in PROGMEM.
73-
InfluxDBClient(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo);
73+
InfluxDBClient(const String &serverUrl, const String &org, const String &bucket, const String &authToken, const char *certInfo);
7474
// Clears instance.
7575
~InfluxDBClient();
7676
// Allows insecure connection by skiping server certificate validation.
@@ -106,15 +106,15 @@ class InfluxDBClient {
106106
// bucket - name of the bucket to write data into
107107
// authToken - InfluxDB 2 authorization token
108108
// serverCert - Optional. InfluxDB 2 server trusted certificate (or CA certificate) or certificate SHA1 fingerprint. Should be stored in PROGMEM. Only in case of https connection.
109-
void setConnectionParams(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo = nullptr);
109+
void setConnectionParams(const String &serverUrl, const String &org, const String &bucket, const String &authToken, const char *certInfo = nullptr);
110110
// Sets parameters for connection to InfluxDB 1
111111
// Must be called before calling any method initiating a connection to server.
112112
// serverUrl - url of the InfluxDB server (e.g. http://localhost:8086)
113113
// db - database name where to store or read data
114114
// user - Optional. User name, in case of server requires authetication
115115
// password - Optional. User password, in case of server requires authetication
116116
// certInfo - Optional. InfluxDB server trusted certificate (or CA certificate) or certificate SHA1 fingerprint. Should be stored in PROGMEM. Only in case of https connection.
117-
void setConnectionParamsV1(const char *serverUrl, const char *db, const char *user = nullptr, const char *password = nullptr, const char *certInfo = nullptr);
117+
void setConnectionParamsV1(const String &serverUrl, const String &db, const String &user = (const char *)nullptr, const String &password = (const char *)nullptr, const char *certInfo = nullptr);
118118
// Creates line protocol string from point data and optional default tags set in WriteOptions.
119119
String pointToLineProtocol(const Point& point);
120120
// Validates connection parameters by conecting to server
@@ -164,6 +164,7 @@ class InfluxDBClient {
164164
// Enables/disables streaming write. This allows sending large batches without allocating buffer.
165165
// It is about 50% slower than writing by allocated buffer (default);
166166
void setStreamWrite(bool enable = true);
167+
//
167168
protected:
168169
// Checks params and sets up security, if needed.
169170
// Returns true in case of success, otherwise false

0 commit comments

Comments
 (0)