Dependencies: EthernetNetIf TextLCD mbed HTTPClient
Diff: CSVParser.cpp
- Revision:
- 0:d73b14dd8351
diff -r 000000000000 -r d73b14dd8351 CSVParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CSVParser.cpp Wed Jun 01 00:49:54 2011 +0000 @@ -0,0 +1,25 @@ +#include "CSVParser.h" + +using namespace std; + +std::vector<std::pair<std::string,std::string> > CSVParser::fields; // field id, description pair vector. + +StockData* CSVParser::parseResult(const char *indata) +{ + StockData *ret = new StockData; + + memcpy(ret->buffer, indata, 256); + ret->buffer[255] = 0; + + char *ptr = strtok(ret->buffer, ","); + for(int i=0;i<fields.size();i++) + { + if(ptr == NULL) break; + + printf("%s : %s\n", fields[i].second.c_str(), ptr); + ret->field[i] = ptr; + ptr = strtok(NULL, ","); + } + + return ret; +} \ No newline at end of file