Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit c9f116a

Browse files
committed
Merge pull request #138 from ed7coyne/both-strings
Support both string types in FirebaseArduino.h
2 parents 7d476b8 + 2ef168c commit c9f116a

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/FirebaseArduino.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "FirebaseArduino.h"
1818

19-
void FirebaseArduino::begin(const char* host, const char* auth) {
19+
void FirebaseArduino::begin(const String& host, const String& auth) {
2020
http_.reset(FirebaseHttpClient::create());
2121
http_->setReuseConnection(true);
2222
host_ = host;
@@ -38,7 +38,7 @@ void FirebaseArduino::set(const String& path, const JsonVariant& value) {
3838
error_ = set.error();
3939
}
4040

41-
FirebaseObject FirebaseArduino::get(const char* path) {
41+
FirebaseObject FirebaseArduino::get(const String& path) {
4242
auto get = FirebaseGet(host_, auth_, path, http_.get());
4343
error_ = get.error();
4444
if (failed()) {
@@ -47,7 +47,7 @@ FirebaseObject FirebaseArduino::get(const char* path) {
4747
return FirebaseObject(get.response());
4848
}
4949

50-
int FirebaseArduino::getInt(const char* path) {
50+
int FirebaseArduino::getInt(const String& path) {
5151
auto get = FirebaseGet(host_, auth_, path, http_.get());
5252
error_ = get.error();
5353
if (failed()) {
@@ -57,7 +57,7 @@ int FirebaseArduino::getInt(const char* path) {
5757
}
5858

5959

60-
float FirebaseArduino::getFloat(const char* path) {
60+
float FirebaseArduino::getFloat(const String& path) {
6161
auto get = FirebaseGet(host_, auth_, path, http_.get());
6262
error_ = get.error();
6363
if (failed()) {
@@ -66,7 +66,7 @@ float FirebaseArduino::getFloat(const char* path) {
6666
return FirebaseObject(get.response()).getFloat();
6767
}
6868

69-
String FirebaseArduino::getString(const char* path) {
69+
String FirebaseArduino::getString(const String& path) {
7070
auto get = FirebaseGet(host_, auth_, path, http_.get());
7171
error_ = get.error();
7272
if (failed()) {
@@ -75,21 +75,20 @@ String FirebaseArduino::getString(const char* path) {
7575
return FirebaseObject(get.response()).getString();
7676
}
7777

78-
bool FirebaseArduino::getBool(const char* path) {
78+
bool FirebaseArduino::getBool(const String& path) {
7979
auto get = FirebaseGet(host_, auth_, path, http_.get());
8080
error_ = get.error();
8181
if (failed()) {
8282
return "";
8383
}
8484
return FirebaseObject(get.response()).getBool();
8585
}
86-
87-
void FirebaseArduino::remove(const char* path) {
86+
void FirebaseArduino::remove(const String& path) {
8887
auto remove = FirebaseRemove(host_, auth_, path, http_.get());
8988
error_ = remove.error();
9089
}
9190

92-
void FirebaseArduino::stream(const char* path) {
91+
void FirebaseArduino::stream(const String& path) {
9392
auto stream = FirebaseStream(host_, auth_, path, http_.get());
9493
error_ = stream.error();
9594
}

src/FirebaseArduino.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FirebaseArduino {
3535
* \param host Your firebase db host, usually X.firebaseio.com.
3636
* \param auth Optional credentials for the db, a secret or token.
3737
*/
38-
void begin(const char* host, const char* auth = "");
38+
void begin(const String& host, const String& auth = "");
3939

4040
/**
4141
* Writes data to a new child location under the parent at path.
@@ -63,47 +63,47 @@ class FirebaseArduino {
6363
* \param path The path to the node you wish to retrieve.
6464
* \return The integer value located at that path. Will only be populated if success() is true.
6565
*/
66-
int getInt(const char* path);
66+
int getInt(const String& path);
6767

6868
/**
6969
* Gets the float value located at path.
7070
* You should check success() after calling.
7171
* \param path The path to the node you wish to retrieve.
7272
* \return The float value located at that path. Will only be populated if success() is true.
7373
*/
74-
float getFloat(const char* path);
74+
float getFloat(const String& path);
7575

7676
/**
7777
* Gets the string value located at path.
7878
* You should check success() after calling.
7979
* \param path The path to the node you wish to retrieve.
8080
* \return The string value located at that path. Will only be populated if success() is true.
8181
*/
82-
String getString(const char* path);
82+
String getString(const String& path);
8383

8484
/**
8585
* Gets the boolean value located at path.
8686
* You should check success() after calling.
8787
* \param path The path to the node you wish to retrieve.
8888
* \return The boolean value located at that path. Will only be populated if success() is true.
8989
*/
90-
bool getBool(const char* path);
90+
bool getBool(const String& path);
9191

9292
/**
9393
* Gets the json object value located at path.
9494
* You should check success() after calling.
9595
* \param path The path to the node you wish to retrieve.
9696
* \return a FirebaseObject value located at that path. Will only be populated if success() is true.
9797
*/
98-
FirebaseObject get(const char* path);
98+
FirebaseObject get(const String& path);
9999

100100
/**
101101
* Remove the node, and possibly entire tree, located at path.
102102
* You should check success() after calling.
103103
* \param path The path to the node you wish to remove,
104104
* including all of its children.
105105
*/
106-
void remove(const char* path);
106+
void remove(const String& path);
107107

108108
/**
109109
* Starts streaming any changes made to the node located at path, including
@@ -113,7 +113,7 @@ class FirebaseArduino {
113113
* monitoring available() and calling readEvent() to get new events.
114114
* \param path The path inside of your db to the node you wish to monitor.
115115
*/
116-
void stream(const char* path);
116+
void stream(const String& path);
117117

118118
/**
119119
* Checks if there are new events available. This is only meaningful once

0 commit comments

Comments
 (0)