Properties.h
Go to the documentation of this file.
00001 #ifndef FACE_CONTOUR_DETECTOR_PROPERTIES_H_
00002 # define FACE_CONTOUR_DETECTOR_PROPERTIES_H_
00003 # include <map>
00004 # include <sstream>
00005 # include <iostream>
00006 # include <fstream>
00007 # include <string>
00008 # include <cassert>
00009 
00010 namespace face_contour_detector {
00011 
00013         class Properties {
00014         public:
00016                 Properties();
00017 
00020                 Properties(const Properties& other);
00021 
00024                 void LoadFromTxtFile(const std::string& file);
00025 
00028                 void LoadFromStream(std::istream& s);
00029 
00033                 void LoadFromStreamNoOverwrite(std::istream& s, std::stringstream& notReadable);
00034 
00038                 void SaveToTxtFile(const std::string& file);
00039 
00040                 void AppendSaveToStream(std::ostream& s);
00041 
00042         #pragma mark Read
00043 
00044 
00045 
00046                 bool Exists(const std::string& key) const;
00050                 std::string ReadString(const std::string& key) const;
00054                 float ReadFloat(const std::string& key) const;
00058                 double ReadDouble(const std::string& key) const;
00062                 int ReadInt(const std::string& key) const;
00066                 bool ReadBool(const std::string& key) const;
00067 
00068         #pragma mark -
00069 
00070         #pragma mark Write
00071 
00072 
00073 
00074                 void Set(const std::string& key, const std::string& value);
00078                 void Set(const std::string& key, const char* value);
00082                 void Set(const std::string& key, int value);
00086                 void Set(const std::string& key, float value);
00090                 void Set(const std::string& key, double value);
00094                 void Set(const std::string& key, bool value);
00095 
00097                 void Clear();
00098 
00099         #pragma mark -
00100 
00101         private:
00102                 std::map<std::string, std::string> m_m;
00103 
00104                 inline std::string& M_Replace(std::string &s, const std::string& sub, const std::string& other);
00105         };
00106 
00107         //Implementation
00108 
00109         inline std::string& Properties::M_Replace(std::string &s, const std::string& sub, const std::string& other) {
00110                 assert(!sub.empty());
00111                 for (size_t b = s.find(sub, 0); b < s.npos; b = s.find(sub, b)) {
00112                         s.replace(b, sub.size(), other);
00113                         b += other.size();
00114                 }
00115                 return s;
00116         }
00117 
00118 } // namespace face_contour_detector
00119 
00120 #endif /* FACE_CONTOUR_DETECTOR_PROPERTIES_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends


face_contour_detector
Author(s): Fabian Wenzelmann and Julian Schmid
autogenerated on Wed Dec 26 2012 16:18:17