problem with a string's format in c++ while doing tcp communication
Posted
by
james t
on Stack Overflow
See other posts from Stack Overflow
or by james t
Published on 2010-12-25T16:50:11Z
Indexed on
2010/12/25
16:53 UTC
Read the original article
Hit count: 168
c++
hi, i am building a simple c++ client, i am splitting the info i get from the server to frames, and pass each frame to a function that processes it, i split the frame into lines using
Poco::StringTokenizer tokenizer(frame, "\n");
i take the first line of the tokenizer which represents the type of frame
StmpCommand command(tokenizer[0]); a StmpCommand is an enum with the different types of messages and the constructor works as follows :
StmpCommand(std::string command): commandType_() {
bool x=command=="CONNECTED";
std::cout<<x<<std::endl;
if ("SUBSCRIBE" == command)
commandType_ = SUBSCRIBE;
else if ("UNSUBSCRIBE" == command)
commandType_ = UNSUBSCRIBE;
else if ("SEND" == command)
commandType_ = SEND;
else if ("BEGIN" == command)
commandType_ = BEGIN;
else if ("COMMIT" == command)
commandType_ = COMMIT;
else if ("CONNECT" == command)
commandType_ = CONNECT;
else if ("MESSAGE" == command)
commandType_ = MESSAGE;
else if ("RECEIPT" == command)
commandType_ = RECEIPT;
else if ("CONNECTED" == command)
commandType_ = CONNECTED;
else if ("DISCONNECT" == command)
commandType_ = DISCONNECT;
else if ("ERROR" == command)
commandType_ = ERROR;
else {
std::cerr<<"Error in building StmpCommand object, unknown type - "<<command<<std::endl;
}
}
the first frame i am trying to proccess is a CONNECTED frame therefor i try to create a StmpCommand with CONNECTED as the constructor's only argument and for some reason i am getting an :
Error in building StmpCommand object, unknown type - CONNECTED
i am clearly passing a string containing CONNECTED but i'm guessing there is something else there that isn't allowing the condition else if ("CONNECTED" == command) to hap
© Stack Overflow or respective owner