]> Creatis software - creaImageIO.git/commitdiff
Big correction in Database query
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Tue, 9 Feb 2010 16:20:34 +0000 (16:20 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Tue, 9 Feb 2010 16:20:34 +0000 (16:20 +0000)
src2/creaImageIOSQLiteTreeHandler.cpp

index e9724c40d63d731096ea697d7757953b6c362446..627db08f7465afd4321302687a5d527d3affee6d 100644 (file)
@@ -502,7 +502,7 @@ namespace creaImageIO
          }
       }
 
-
+       
     // Create the attributes table for Root (i.e. Tree)
     LevelDescriptor::AttributeDescriptorListType::const_iterator a;
     for (a = GetTree().GetAttributeDescriptorList(0).begin();
@@ -533,22 +533,21 @@ namespace creaImageIO
 
   //========================================================================
   /// 
-  std::string& SQLformat(std::string& str)
+  void SQLformat(std::string i_str, std::string &o_str)
   {
-    // quote must be doubled
-    boost::algorithm::replace_all(str,"'","''");
-    // Found strange strings which contained NULL char INSIDE string 
-    int i,size=str.size();
-    for (i=0;i<size;++i) 
-      {
-       if (str[i]==0) 
-         {
-           str = str.substr(0,i);
-           break;
-         }
-      }
-    //    if (i<str.size())
-    return str;
+               // quote must be doubled
+               boost::algorithm::replace_all(i_str,"'","''");
+               // Found strange strings which contained NULL char INSIDE string 
+               int i,size=i_str.size();
+               for (i=0;i<size;++i) 
+               {
+                       if (i_str[i]==0) 
+                       {
+                               i_str = i_str.substr(0,i);
+                               break;
+                         }
+               }
+               o_str = i_str;
   }
   //========================================================================
   
@@ -559,6 +558,7 @@ namespace creaImageIO
     GimmickMessage(4,"SQLAppendAttributesValues"<<std::endl);
     std::string atts="";
     std::string values="";
+       std::string out ="";
     tree::Node::AttributeMapType::iterator i;
     for (i =  n->GetAttributeMap().begin();
         i != n->GetAttributeMap().end();
@@ -570,7 +570,8 @@ namespace creaImageIO
          }
 
        atts += "'" + i->first + "'";
-       values += "'" + SQLformat(i->second) + "'"; 
+       SQLformat(i->second, out);
+       values += "'" + out + "'"; 
        atts += ",";
        values += ",";
        GimmickMessage(4,"'"<<i->first<<"' = '"<<i->second<<"'"<<std::endl);