/[usata]/usata2/src/texture-meta-parser.cpp
ViewVC logotype

Diff of /usata2/src/texture-meta-parser.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by skunix, Sun Dec 26 02:29:33 2004 UTC revision 1.2 by skunix, Sun Dec 26 08:03:34 2004 UTC
# Line 11  Line 11 
11  // http://www.fsf.org/licenses/gpl.html.  // http://www.fsf.org/licenses/gpl.html.
12  //  //
13  // $Log$  // $Log$
14    // Revision 1.2  2004/12/26 08:03:34  skunix
15    // changed lambda::bind's to boost::binds
16    //
17  // Revision 1.1  2004/12/26 02:29:33  skunix  // Revision 1.1  2004/12/26 02:29:33  skunix
18  // Texture manager basics written, and texture-meta-parser added  // Texture manager basics written, and texture-meta-parser added
19  //  //
# Line 18  Line 21 
21  #include <fstream>  #include <fstream>
22  #include <iostream>  #include <iostream>
23  #include <deque>  #include <deque>
24    
25  #include <boost/function.hpp>  #include <boost/function.hpp>
26  #include <boost/format.hpp>  #include <boost/format.hpp>
27    #include <boost/filesystem/fstream.hpp>
28  #include <boost/algorithm/string.hpp>  #include <boost/algorithm/string.hpp>
29  #include <boost/tokenizer.hpp>  #include <boost/tokenizer.hpp>
30  #include <boost/tuple/tuple.hpp>  #include <boost/tuple/tuple.hpp>
31    
32  #include "texture.hpp"  #include "texture.hpp"
33  #include "texture-meta.hpp"  #include "texture-meta.hpp"
34  #include "util.hpp"  #include "util.hpp"
35    #include "log.hpp"
36    
37  namespace usata  namespace usata
38  {  {
39          typedef boost::tuple<bool, std::string> ErResult;          typedef boost::tuple<bool, std::string> ErResult;
# Line 55  namespace usata Line 63  namespace usata
63          {          {
64                  using std::string;                  using std::string;
65                  string::size_type f = str.find('=');                  string::size_type f = str.find('=');
66            
67                  string kw(str),value;                  string kw(str),value;
68                  if (f!=string::npos)                  if (f!=string::npos)
69                  {                  {
# Line 84  namespace usata Line 93  namespace usata
93          }          }
94    
95          bool          bool
96          texture_meta_parse(const std::string& filename, const AddTexMetaFunc&add)          texture_meta_parse(const boost::filesystem::path& p, const AddTexMetaFunc&add)
97          {          {
98                  std::ifstream file;                  boost::filesystem::ifstream file;
99                    boost::filesystem::path directory = p.branch_path();
100    
101                    log::Stream logstream(&log::server);
102                  unsigned line_num(0);                  unsigned line_num(0);
103                  std::string line;                  std::string line;
104                  file.open(filename.c_str());                  file.open(p);
105                                    
106                  if (!file.is_open())                  if (!file.is_open())
107                  {                  {
108                            logstream << log::set_level(log::Level::ERROR) << "couldnt open\n";
109                          return false;                          return false;
110                  }                  }
111    
# Line 133  namespace usata Line 146  namespace usata
146                                                    
147                          std::string tfilename = line_proc.front();                          std::string tfilename = line_proc.front();
148                          line_proc.pop_front();                          line_proc.pop_front();
149                          TextureMeta x(tfilename);                          TextureMeta x(directory / tfilename);
150                          for (std::deque<string>::iterator it=line_proc.begin(); it!=line_proc.end();++it)                          for (std::deque<string>::iterator it=line_proc.begin(); it!=line_proc.end();++it)
151                          {                          {
152                                  ErResult er=texture_meta_proc_attrib(*it, x);                                  ErResult er=texture_meta_proc_attrib(*it, x);
153                                  if (er.get<0>() == false)                                  if (er.get<0>() == false)
154                                  {                                  {
155                                          std::cerr << boost::format("%1% in '%2%' on line %3%") %                                          boost::format msg("%1% in '%2%' on line %3%");
156                                                          er.get<1>() % filename% line_num<<std::endl; ;                                          msg % er.get<1>() % p.native_file_string()% line_num ;
157                                            std::cout << msg << std::endl;
158                                            logstream << log::set_level(log::Level::WARNING) << msg.str();
159                                  }                                  }
160                          }                          }
161                          add(&x);                                  add(&x);        

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26