00001 #ifndef NUMTOSTR_H
00002 #define NUMTOSTR_H
00003
00004 #include <iostream>
00005 #include <string>
00006
00008 inline std::string dbltostr(double d){
00009 std::string s = "";
00010
00011 std::ostringstream o;
00012 if(o<<d){
00013 s = o.str();
00014
00015 return s;
00016 }
00017 else
00018 return s;
00019 }
00020
00022 inline std::string inttostr(int i){
00023 std::string s = "";
00024
00025 std::ostringstream o;
00026
00027 if(o<<i){
00028 s = o.str();
00029
00030 return s;
00031 }
00032 else
00033 return s;
00034 }
00035
00037 std::string
00038 stripQuote(std::string& s) {
00039 char singlequote = 39 + '\0';
00040 std::ostringstream o;
00041 o<<singlequote;
00042 std::string f = o.str();
00043 std::string r = "\\";
00044 unsigned int found = s.find(f);
00045
00046 vector<int> myvec;
00047 while(found != string::npos) {
00048 s.replace(found, f.length(), r);
00049 myvec.insert(myvec.begin(), found);
00050
00051 found = s.find(f);
00052 }
00053 if(myvec.size()==0){
00054 return s;
00055 }
00056 else{
00057 for(unsigned int i = 0; i< myvec.size(); i++){
00058 s.insert(myvec[i]+1, "\'");
00059 }
00060 }
00061
00062 return s;
00063 }
00064
00065
00067 isect_t*
00068 convertStringPoint(std::string& pt){
00069
00070 std::string lb = "(";
00071 std::string rb = ")";
00072 std::string sp = " ";
00073 std::string comma = ",";
00074 unsigned int flb = pt.find(lb);
00075 unsigned int frb = pt.find(rb);
00076
00077 pt.replace(flb, 1, sp);
00078 pt.replace(frb, 1, sp);
00079
00080 std::string x = pt.substr(1, pt.find(comma)-1);
00081 std::string y = pt.substr(pt.find(comma)+1, pt.length());
00082
00083 isect_t* i = new isect_t;
00084 i->x = (double)atol(x.c_str());
00085 i->y = (double)atol(y.c_str());
00086 return i;
00087 }
00088
00090 std::vector<segpt>
00091 convertStringPath(std::string& path){
00092 std::string llb1 = "[(";
00093 std::string rrb1 = ")]";
00094 std::string llb2 = "((";
00095 std::string rrb2 = "))";
00096 }
00097
00098
00099
00100
00101
00102 #endif