Code cleanup, removed todos
This commit is contained in:
parent
983764cc71
commit
fe7f8f6eb8
6 changed files with 18 additions and 20 deletions
|
@ -42,20 +42,6 @@ void Message::addArgument(const char *value) {
|
|||
this->addArgument(TelldusCore::charToWstring(value));
|
||||
}
|
||||
|
||||
std::wstring Message::charUnsignedToWstring(const unsigned char value) {
|
||||
//todo move?
|
||||
std::wstringstream st;
|
||||
st << value;
|
||||
return st.str();
|
||||
}
|
||||
|
||||
std::wstring Message::intToWstring(int value) {
|
||||
//todo move?
|
||||
std::wstringstream st;
|
||||
st << value;
|
||||
return st.str();
|
||||
}
|
||||
|
||||
bool Message::nextIsInt(const std::wstring &message) {
|
||||
if (message.length() == 0) {
|
||||
return false;
|
||||
|
|
|
@ -14,8 +14,6 @@ namespace TelldusCore {
|
|||
void addArgument(int);
|
||||
void addArgument(const char *);
|
||||
|
||||
static std::wstring charUnsignedToWstring(const unsigned char value);
|
||||
static std::wstring intToWstring(int value);
|
||||
static bool nextIsInt(const std::wstring &);
|
||||
static bool nextIsString(const std::wstring &);
|
||||
|
||||
|
|
|
@ -70,6 +70,12 @@ int TelldusCore::charToInteger(const char *input){
|
|||
return retval;
|
||||
}
|
||||
|
||||
std::wstring TelldusCore::charUnsignedToWstring(const unsigned char value) {
|
||||
std::wstringstream st;
|
||||
st << value;
|
||||
return st.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method doesn't support all locales
|
||||
*/
|
||||
|
@ -80,6 +86,12 @@ bool TelldusCore::comparei(std::wstring stringA, std::wstring stringB) {
|
|||
return stringA == stringB;
|
||||
}
|
||||
|
||||
std::wstring TelldusCore::intToWstring(int value) {
|
||||
std::wstringstream st;
|
||||
st << value;
|
||||
return st.str();
|
||||
}
|
||||
|
||||
int TelldusCore::wideToInteger(const std::wstring &input){
|
||||
std::wstringstream inputstream;
|
||||
inputstream << input;
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
namespace TelldusCore {
|
||||
std::wstring charToWstring(const char *value);
|
||||
int charToInteger(const char *value);
|
||||
std::wstring charUnsignedToWstring(const unsigned char value);
|
||||
|
||||
bool comparei(std::wstring stringA, std::wstring stringB);
|
||||
std::wstring intToWstring(int value);
|
||||
std::string wideToString(const std::wstring &input);
|
||||
|
||||
int wideToInteger(const std::wstring &input);
|
||||
|
|
|
@ -203,7 +203,7 @@ int Device::maskUnsupportedMethods(int methods, int supportedMethods) {
|
|||
}
|
||||
|
||||
// Execute -> On
|
||||
if ((methods & TELLSTICK_EXECUTE) && !(supportedMethods & TELLSTICK_EXECUTE)) { //TODO ok everywhere? (check down/up too)
|
||||
if ((methods & TELLSTICK_EXECUTE) && !(supportedMethods & TELLSTICK_EXECUTE)) {
|
||||
methods |= TELLSTICK_TURNON;
|
||||
}
|
||||
|
||||
|
|
|
@ -421,7 +421,7 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data){
|
|||
}
|
||||
if(retval == TELLSTICK_SUCCESS && device->getType() != TELLSTICK_TYPE_SCENE && device->getMethods() & action) {
|
||||
//if method isn't explicitly supported by device, but used anyway as a fallback (i.e. bell), don't change state
|
||||
std::wstring datastring = TelldusCore::Message::charUnsignedToWstring(data);
|
||||
std::wstring datastring = TelldusCore::charUnsignedToWstring(data);
|
||||
if (this->triggerDeviceStateChange(deviceId, action, datastring)) {
|
||||
device->setLastSentCommand(action, datastring);
|
||||
d->set.setDeviceState(deviceId, action, datastring);
|
||||
|
@ -467,7 +467,7 @@ int DeviceManager::doGroupAction(const std::wstring devices, const int action, c
|
|||
deviceReturnValue = doGroupAction(DeviceManager::getDeviceParameter(deviceId, L"devices", L""), action, data, childType, deviceId, duplicateDeviceIds);
|
||||
|
||||
if(deviceReturnValue == TELLSTICK_SUCCESS) {
|
||||
std::wstring datastring = TelldusCore::Message::charUnsignedToWstring(data);
|
||||
std::wstring datastring = TelldusCore::charUnsignedToWstring(data);
|
||||
if (this->triggerDeviceStateChange(deviceId, action, datastring)) {
|
||||
DeviceManager::setDeviceLastSentCommand(deviceId, action, datastring);
|
||||
d->set.setDeviceState(deviceId, action, datastring);
|
||||
|
@ -577,7 +577,6 @@ void DeviceManager::handleControllerMessage(const ControllerEventData &eventData
|
|||
std::list<std::string> parameters = it->second->getParametersForProtocol();
|
||||
bool thisDevice = true;
|
||||
for (std::list<std::string>::iterator paramIt = parameters.begin(); paramIt != parameters.end(); ++paramIt){
|
||||
//TODO more efficient conversion/compare? wstring or not?
|
||||
if(!TelldusCore::comparei(it->second->getParameter(TelldusCore::charToWstring((*paramIt).c_str())), TelldusCore::charToWstring(msg.getParameter(*paramIt).c_str()))){
|
||||
thisDevice = false;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue