inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/lutmanip
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_lutmanip
00005 #define inlib_lutmanip
00006 
00007 #include "lut"
00008 #include "smanip"
00009 
00010 namespace inlib {
00011 
00012 inline bool lut_from_string(std::ostream& a_out,
00013                             const std::string& a_s,
00014                             inlib::lut<float,unsigned char>& a_lut) {
00015   std::vector<std::string> words;
00016   inlib::words(a_s,",",false,words);
00017   if(words.size()!=3) {
00018     a_out << "lut_from_string :" 
00019           << " bad syntax in a_ " << inlib::sout(a_s)
00020           << ". <float:min>,<float:max>,<unsigned int:num> expected."
00021           << std::endl;    
00022     return false;
00023   }
00024   float mn,mx;
00025   if(!inlib::to<float>(words[0],mn)) {
00026     a_out << "lut_from_string :" 
00027           << " bad syntax in a_ " << inlib::sout(a_s)
00028           << ". " << words[0] << " not a float."
00029           << std::endl;    
00030     return false;
00031   }
00032   if(!inlib::to<float>(words[1],mx)) {
00033     a_out << "lut_from_string :" 
00034           << " bad syntax in a_ " << inlib::sout(a_s)
00035           << ". " << words[1] << " not a float."
00036           << std::endl;    
00037     return false;
00038   }
00039   unsigned int num;
00040   if(!inlib::to<unsigned int>(words[2],num)) {
00041     a_out << "lut_from_string :" 
00042           << " bad syntax in a_ " << inlib::sout(a_s)
00043           << ". " << words[2] << " not an unsigned int."
00044           << std::endl;    
00045     return false;
00046   }  
00047   a_lut = inlib::lut<float,unsigned char>(mn,mx,num);
00048   return true;
00049 }
00050 
00051 }
00052 
00053 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines