Skip to content

Commit fa9bb38

Browse files
committed
More std::string -> String
1 parent 7911c4c commit fa9bb38

File tree

12 files changed

+44
-44
lines changed

12 files changed

+44
-44
lines changed

libraries/BLE/examples/Beacon_Scanner/Beacon_Scanner.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
3939

4040
if (advertisedDevice.haveManufacturerData() == true)
4141
{
42-
std::string strManufacturerData = advertisedDevice.getManufacturerData();
42+
String strManufacturerData = advertisedDevice.getManufacturerData();
4343

4444
uint8_t cManufacturerData[100];
4545
strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0);
@@ -69,7 +69,7 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
6969
Serial.println("Found an EddystoneURL beacon!");
7070
BLEEddystoneURL EddystoneURL = BLEEddystoneURL(&advertisedDevice);
7171
Serial.printf("URL bytes: 0x");
72-
std::string url = EddystoneURL.getURL();
72+
String url = EddystoneURL.getURL();
7373
for(auto byte : url){
7474
Serial.printf("%02X", byte);
7575
}

libraries/BLE/examples/Client/Client.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ bool connectToServer() {
8080

8181
// Read the value of the characteristic.
8282
if(pRemoteCharacteristic->canRead()) {
83-
std::string value = pRemoteCharacteristic->readValue();
83+
String value = pRemoteCharacteristic->readValue();
8484
Serial.print("The characteristic value was: ");
8585
Serial.println(value.c_str());
8686
}

libraries/BLE/examples/EddystoneURL_Beacon/EddystoneURL_Beacon.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int setBeacon()
6060
EddystoneURL.setPower(BEACON_POWER); // This is only information about the power. The actual power is set by `BLEDevice::setPower(BEACON_POWER)`
6161
if(EddystoneURL.setSmartURL(URL[bootcount%(sizeof(URL)/sizeof(URL[0]))])){
6262
String frame = EddystoneURL.getFrame();
63-
std::string data(EddystoneURL.getFrame().c_str(), frame.length());
63+
String data(EddystoneURL.getFrame().c_str(), frame.length());
6464
oAdvertisementData.addData(data);
6565
oScanResponseData.setName("ESP32 URLBeacon");
6666
pAdvertising->setAdvertisementData(oAdvertisementData);

libraries/BLE/examples/UART/UART.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class MyServerCallbacks: public BLEServerCallbacks {
5050

5151
class MyCallbacks: public BLECharacteristicCallbacks {
5252
void onWrite(BLECharacteristic *pCharacteristic) {
53-
std::string rxValue = pCharacteristic->getValue();
53+
String rxValue = pCharacteristic->getValue();
5454

5555
if (rxValue.length() > 0) {
5656
Serial.println("*********");

libraries/BLE/examples/Write/Write.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class MyCallbacks: public BLECharacteristicCallbacks {
1818
void onWrite(BLECharacteristic *pCharacteristic) {
19-
std::string value = pCharacteristic->getValue();
19+
String value = pCharacteristic->getValue();
2020

2121
if (value.length() > 0) {
2222
Serial.println("*********");

libraries/BLE/examples/iBeacon/iBeacon.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MyServerCallbacks: public BLEServerCallbacks {
4949

5050
class MyCallbacks: public BLECharacteristicCallbacks {
5151
void onWrite(BLECharacteristic *pCharacteristic) {
52-
std::string rxValue = pCharacteristic->getValue();
52+
String rxValue = pCharacteristic->getValue();
5353

5454
if (rxValue.length() > 0) {
5555
Serial.println("*********");

libraries/BLE/src/BLEAddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ BLEAddress::BLEAddress(esp_bd_addr_t address) {
4242
*
4343
* @param [in] stringAddress The hex representation of the address.
4444
*/
45-
BLEAddress::BLEAddress(std::string stringAddress) {
45+
BLEAddress::BLEAddress(String stringAddress) {
4646
if (stringAddress.length() != 17) return;
4747

4848
int data[6];

libraries/BLE/src/BLEBeacon.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ BLEBeacon::BLEBeacon() {
2525
memset(m_beaconData.proximityUUID, 0, sizeof(m_beaconData.proximityUUID));
2626
} // BLEBeacon
2727

28-
std::string BLEBeacon::getData() {
29-
return std::string((char*) &m_beaconData, sizeof(m_beaconData));
28+
String BLEBeacon::getData() {
29+
return String((char*) &m_beaconData, sizeof(m_beaconData));
3030
} // getData
3131

3232
uint16_t BLEBeacon::getMajor() {
@@ -52,7 +52,7 @@ int8_t BLEBeacon::getSignalPower() {
5252
/**
5353
* Set the raw data for the beacon record.
5454
*/
55-
void BLEBeacon::setData(std::string data) {
55+
void BLEBeacon::setData(String data) {
5656
if (data.length() != sizeof(m_beaconData)) {
5757
log_e("Unable to set the data ... length passed in was %d and expected %d", data.length(), sizeof(m_beaconData));
5858
return;

libraries/BLE/src/BLEBeacon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class BLEBeacon {
2929
} __attribute__((packed)) m_beaconData;
3030
public:
3131
BLEBeacon();
32-
std::string getData();
32+
String getData();
3333
uint16_t getMajor();
3434
uint16_t getMinor();
3535
uint16_t getManufacturerId();
3636
BLEUUID getProximityUUID();
3737
int8_t getSignalPower();
38-
void setData(std::string data);
38+
void setData(String data);
3939
void setMajor(uint16_t major);
4040
void setMinor(uint16_t minor);
4141
void setManufacturerId(uint16_t manufacturerId);

libraries/BLE/src/BLEEddystoneURL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ int BLEEddystoneURL::setSmartURL(String url) {
248248
}
249249

250250
for(uint8_t i = 0; i < 0x0E; ++i){
251-
std::string std_url(url.c_str());
252-
std::string std_suffix(EDDYSTONE_URL_SUFFIX[i].c_str());
251+
String std_url(url.c_str());
252+
String std_suffix(EDDYSTONE_URL_SUFFIX[i].c_str());
253253
size_t found_pos = std_url.find(std_suffix);
254254
//log_d("check if in url \"%s\" can find suffix \"%s\": found_pos = %d", std_url.c_str(), std_suffix.c_str(), found_pos);
255-
if(found_pos != std::string::npos){
255+
if(found_pos != String::npos){
256256
hasSuffix = true;
257257
suffix = i;
258258
break;

libraries/BLE/src/GeneralUtils.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int base64EncodedLength(size_t length) {
3030
} // base64EncodedLength
3131

3232

33-
static int base64EncodedLength(const std::string& in) {
33+
static int base64EncodedLength(const String& in) {
3434
return base64EncodedLength(in.length());
3535
} // base64EncodedLength
3636

@@ -55,7 +55,7 @@ static void a4_to_a3(unsigned char* a3, unsigned char* a4) {
5555
* @param [in] in
5656
* @param [out] out
5757
*/
58-
bool GeneralUtils::base64Encode(const std::string& in, std::string* out) {
58+
bool GeneralUtils::base64Encode(const String& in, String* out) {
5959
int i = 0, j = 0;
6060
size_t enc_len = 0;
6161
unsigned char a3[3];
@@ -64,7 +64,7 @@ bool GeneralUtils::base64Encode(const std::string& in, std::string* out) {
6464
out->resize(base64EncodedLength(in));
6565

6666
int input_len = in.size();
67-
std::string::const_iterator input = in.begin();
67+
String::const_iterator input = in.begin();
6868

6969
while (input_len--) {
7070
a3[i++] = *(input++);
@@ -121,7 +121,7 @@ void GeneralUtils::dumpInfo() {
121121
* @param [in] c The character to look form.
122122
* @return True if the string ends with the given character.
123123
*/
124-
bool GeneralUtils::endsWith(std::string str, char c) {
124+
bool GeneralUtils::endsWith(String str, char c) {
125125
if (str.empty()) {
126126
return false;
127127
}
@@ -132,11 +132,11 @@ bool GeneralUtils::endsWith(std::string str, char c) {
132132
} // endsWidth
133133

134134

135-
static int DecodedLength(const std::string& in) {
135+
static int DecodedLength(const String& in) {
136136
int numEq = 0;
137137
int n = (int) in.size();
138138

139-
for (std::string::const_reverse_iterator it = in.rbegin(); *it == '='; ++it) {
139+
for (String::const_reverse_iterator it = in.rbegin(); *it == '='; ++it) {
140140
++numEq;
141141
}
142142
return ((6 * n) / 8) - numEq;
@@ -158,14 +158,14 @@ static unsigned char b64_lookup(unsigned char c) {
158158
* @param [in] in The string to be decoded.
159159
* @param [out] out The resulting data.
160160
*/
161-
bool GeneralUtils::base64Decode(const std::string& in, std::string* out) {
161+
bool GeneralUtils::base64Decode(const String& in, String* out) {
162162
int i = 0, j = 0;
163163
size_t dec_len = 0;
164164
unsigned char a3[3];
165165
unsigned char a4[4];
166166

167167
int input_len = in.size();
168-
std::string::const_iterator input = in.begin();
168+
String::const_iterator input = in.begin();
169169

170170
out->resize(DecodedLength(in));
171171

@@ -212,8 +212,8 @@ bool GeneralUtils::base64Decode(const std::string& in, std::string* out) {
212212
/*
213213
void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
214214
uint32_t index=0;
215-
std::stringstream ascii;
216-
std::stringstream hex;
215+
Stringstream ascii;
216+
Stringstream hex;
217217
char asciiBuf[80];
218218
char hexBuf[80];
219219
hex.str("");
@@ -251,8 +251,8 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
251251
/*
252252
void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
253253
uint32_t index=0;
254-
static std::stringstream ascii;
255-
static std::stringstream hex;
254+
static Stringstream ascii;
255+
static Stringstream hex;
256256
hex.str("");
257257
ascii.str("");
258258
while(index < length) {
@@ -331,11 +331,11 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
331331
* @param ip The 4 byte IP address.
332332
* @return A string representation of the IP address.
333333
*/
334-
std::string GeneralUtils::ipToString(uint8_t *ip) {
334+
String GeneralUtils::ipToString(uint8_t *ip) {
335335
auto size = 16;
336336
char *val = (char*)malloc(size);
337337
snprintf(val, size, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
338-
std::string res(val);
338+
String res(val);
339339
free(val);
340340
return res;
341341
} // ipToString
@@ -347,12 +347,12 @@ std::string GeneralUtils::ipToString(uint8_t *ip) {
347347
* @param [in] delimiter The delimiter characters.
348348
* @return A vector of strings that are the split of the input.
349349
*/
350-
std::vector<std::string> GeneralUtils::split(std::string source, char delimiter) {
350+
std::vector<String> GeneralUtils::split(String source, char delimiter) {
351351
// See also: https://stackoverflow.com/questions/5167625/splitting-a-c-stdstring-using-tokens-e-g
352-
std::vector<std::string> strings;
352+
std::vector<String> strings;
353353
std::size_t current, previous = 0;
354354
current = source.find(delimiter);
355-
while (current != std::string::npos) {
355+
while (current != String::npos) {
356356
strings.push_back(trim(source.substr(previous, current - previous)));
357357
previous = current + 1;
358358
current = source.find(delimiter, previous);
@@ -523,9 +523,9 @@ const char* GeneralUtils::wifiErrorToString(uint8_t errCode) {
523523
* @param [in] value The string to convert to lower case.
524524
* @return A lower case representation of the string.
525525
*/
526-
std::string GeneralUtils::toLower(std::string& value) {
526+
String GeneralUtils::toLower(String& value) {
527527
// Question: Could this be improved with a signature of:
528-
// std::string& GeneralUtils::toLower(std::string& value)
528+
// String& GeneralUtils::toLower(String& value)
529529
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
530530
return value;
531531
} // toLower
@@ -534,9 +534,9 @@ std::string GeneralUtils::toLower(std::string& value) {
534534
/**
535535
* @brief Remove white space from a string.
536536
*/
537-
std::string GeneralUtils::trim(const std::string& str) {
537+
String GeneralUtils::trim(const String& str) {
538538
size_t first = str.find_first_not_of(' ');
539-
if (std::string::npos == first) return str;
539+
if (String::npos == first) return str;
540540
size_t last = str.find_last_not_of(' ');
541541
return str.substr(first, (last - first + 1));
542542
} // trim

libraries/BLE/src/GeneralUtils.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
*/
1919
class GeneralUtils {
2020
public:
21-
static bool base64Decode(const std::string& in, std::string* out);
22-
static bool base64Encode(const std::string& in, std::string* out);
21+
static bool base64Decode(const String& in, String* out);
22+
static bool base64Encode(const String& in, String* out);
2323
static void dumpInfo();
24-
static bool endsWith(std::string str, char c);
24+
static bool endsWith(String str, char c);
2525
static const char* errorToString(esp_err_t errCode);
2626
static const char* wifiErrorToString(uint8_t value);
2727
static void hexDump(const uint8_t* pData, uint32_t length);
28-
static std::string ipToString(uint8_t* ip);
29-
static std::vector<std::string> split(std::string source, char delimiter);
30-
static std::string toLower(std::string& value);
31-
static std::string trim(const std::string& str);
28+
static String ipToString(uint8_t* ip);
29+
static std::vector<String> split(String source, char delimiter);
30+
static String toLower(String& value);
31+
static String trim(const String& str);
3232

3333
};
3434

0 commit comments

Comments
 (0)