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 {
00072 ZYPP_THROW(Exception("Can't read patches file "+file_r.asString()));
00073 }
00074 std::string buffer;
00075
00076 getline(file, buffer);
00077
00078 regex rx("^([\\S]+)( (.*))?$");
00079 boost::smatch what;
00080
00081 if (boost::regex_match(buffer, what, rx))
00082 {
00083
00084 entry_r.dir = Pathname(what[1]);
00085 entry_r.comment = what[3];
00086 }
00087 else
00088 {
00089
00090 }
00091
00092 while (file && !file.eof())
00093 {
00094 getline(file, buffer);
00095 rx = boost::regex("^(.+)-(.+)$");
00096 if (boost::regex_match(buffer, what, rx, boost::match_extra))
00097 {
00098 zypp::parser::tagfile::dumpRegexpResults(what);
00099 entry_r.products.insert(std::pair<std::string, std::string>(what[1],what[2]));
00100 }
00101 else
00102 {
00103
00104 }
00105
00106 }
00107 }
00108
00110 }
00113 }
00116 }