00001
00002
00003
00004
00005
00006
00007
00008
00012 #include <iostream>
00013 #include <fstream>
00014 #include <sstream>
00015
00016 #include <boost/tokenizer.hpp>
00017 #include <boost/algorithm/string.hpp>
00018
00019 #include "zypp/base/Logger.h"
00020 #include "zypp/base/Exception.h"
00021 #include "zypp/base/PtrTypes.h"
00022 #include "zypp/base/String.h"
00023
00024 #include "zypp/parser/tagfile/TagFileParser.h"
00025 #include "zypp/source/susetags/MediaPatchesMetadataParser.h"
00026 #include <boost/regex.hpp>
00027
00028 using namespace std;
00029 using namespace boost;
00030
00032 namespace zypp
00033 {
00034
00035 namespace source
00036 {
00037
00038 namespace susetags
00039 {
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00063
00064
00065
00066
00067 void MediaPatchesMetadataParser::parse( const Pathname & file_r, MediaPatchesEntry &entry_r )
00068 {
00069 std::ifstream file(file_r.asString().c_str());
00070 if (!file) {
00071 ZYPP_THROW(Exception("Can't read patches file "+file_r.asString()));
00072 }
00073 std::string buffer;
00074
00075 getline(file, buffer);
00076
00077 regex rx("^([\\S]+)( (.*))?$");
00078 boost::smatch what;
00079
00080 if(boost::regex_match(buffer, what, rx))
00081 {
00082
00083 entry_r.dir = Pathname(what[1]);
00084 entry_r.comment = what[3];
00085 }
00086 else
00087 {
00088
00089 }
00090
00091 while(file && !file.eof())
00092 {
00093 getline(file, buffer);
00094 rx = boost::regex("^(.+)-(.+)$");
00095 if(boost::regex_match(buffer, what, rx, boost::match_extra))
00096 {
00097 zypp::parser::tagfile::dumpRegexpResults(what);
00098 entry_r.products.insert(std::pair<std::string, std::string>(what[1],what[2]));
00099 }
00100 else
00101 {
00102
00103 }
00104
00105 }
00106 }
00107
00109 }
00112 }
00115 }