Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI-1 LibPN532 nRF24L01P xiugai
converters.h
- Committer:
- brainliang
- Date:
- 2019-11-07
- Revision:
- 7:6f8157c58241
- Parent:
- 6:7db9b13ece76
File content as of revision 7:6f8157c58241:
#pragma once
#include <cstdlib>
#include <string>
namespace std{
static inline int stoi(const string &s) {
return atoi(s.c_str());
}
static inline long stol(const string &s) {
return atol(s.c_str());
}
static inline float stof(const string &s) {
return float(atof(s.c_str()));
}
#define _c_to_string(fmt,val) { \
char buf[16];\
snprintf(buf, sizeof(buf), fmt, val);\
return string(buf);\
}
static inline string to_string(bool v) {
_c_to_string("%d", (int)v);
}
static inline string to_string(char v) {
_c_to_string("%c", v);
}
static inline string to_string(int v) {
_c_to_string("%d", v);
}
static inline string to_string(long v) {
_c_to_string("%ld", v);
}
static inline string to_string(float v) {
_c_to_string("%f", v);
}
}
inline bool _p(bool x) { return x; }
inline char _p(char x) { return x; }
inline int _p(int x) { return x; }
inline long _p(long x) { return x; }
inline float _p(float x) { return x; }
inline void* _p(void* x) { return x; }
inline const char* _p(const std::string &x) { return x.c_str(); }