[zypp-devel] ok to commit?
diff --git a/zypp/media/MetaLinkParser.cc b/zypp/media/MetaLinkParser.cc index 056a7f5..2c11cf6 100644 --- a/zypp/media/MetaLinkParser.cc +++ b/zypp/media/MetaLinkParser.cc @@ -386,16 +386,21 @@ MetaLinkParser::~MetaLinkParser() } void -MetaLinkParser::parse(string filename) +MetaLinkParser::parse(Pathname filename) +{ + parse(InputStream(filename)); +} + +void +MetaLinkParser::parse(const InputStream &is) { char buf[4096]; - std::ifstream is(filename.c_str()); - if (!is) + if (!is.stream()) ZYPP_THROW(Exception("MetaLinkParser: no such file")); - while (is.good()) + while (is.stream().good()) { - is.read(buf, sizeof(buf)); - parseBytes(buf, is.gcount()); + is.stream().read(buf, sizeof(buf)); + parseBytes(buf, is.stream().gcount()); } parseEnd(); } diff --git a/zypp/media/MetaLinkParser.h b/zypp/media/MetaLinkParser.h index eacc486..b9073d0 100644 --- a/zypp/media/MetaLinkParser.h +++ b/zypp/media/MetaLinkParser.h @@ -16,6 +16,7 @@ #include "zypp/base/Exception.h" #include "zypp/base/NonCopyable.h" +#include "zypp/base/InputStream.h" #include "zypp/media/MediaBlockList.h" #include "zypp/Url.h" @@ -33,7 +34,13 @@ public: * parse a file consisting of metalink xml data * \throws Exception **/ - void parse(std::string filename); + void parse(Pathname filename); + -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Dominik Heidler write:
diff --git a/zypp/media/MetaLinkParser.cc b/zypp/media/MetaLinkParser.cc index 056a7f5..2c11cf6 100644 --- a/zypp/media/MetaLinkParser.cc +++ b/zypp/media/MetaLinkParser.cc @@ -386,16 +386,21 @@ MetaLinkParser::~MetaLinkParser() }
void -MetaLinkParser::parse(string filename) +MetaLinkParser::parse(Pathname filename) +{ + parse(InputStream(filename)); +} + +void +MetaLinkParser::parse(const InputStream &is) { char buf[4096]; - std::ifstream is(filename.c_str()); - if (!is) + if (!is.stream()) ZYPP_THROW(Exception("MetaLinkParser: no such file")); - while (is.good()) + while (is.stream().good()) { - is.read(buf, sizeof(buf)); - parseBytes(buf, is.gcount()); + is.stream().read(buf, sizeof(buf)); + parseBytes(buf, is.stream().gcount()); } parseEnd(); } diff --git a/zypp/media/MetaLinkParser.h b/zypp/media/MetaLinkParser.h index eacc486..b9073d0 100644 --- a/zypp/media/MetaLinkParser.h +++ b/zypp/media/MetaLinkParser.h @@ -16,6 +16,7 @@
#include "zypp/base/Exception.h" #include "zypp/base/NonCopyable.h" +#include "zypp/base/InputStream.h" #include "zypp/media/MediaBlockList.h" #include "zypp/Url.h"
@@ -33,7 +34,13 @@ public: * parse a file consisting of metalink xml data * \throws Exception **/ - void parse(std::string filename); + void parse(Pathname filename); +
Why there is not parse with InputStream variant in header? I think it could be useful, as it allows to parse stream e.g. directly from network. Josef -- Josef Reidinger YaST team maintainer of perl-Bootloader and parts of webyast -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Josef Reidinger write:
Dominik Heidler write:
diff --git a/zypp/media/MetaLinkParser.cc b/zypp/media/MetaLinkParser.cc index 056a7f5..2c11cf6 100644 --- a/zypp/media/MetaLinkParser.cc +++ b/zypp/media/MetaLinkParser.cc @@ -386,16 +386,21 @@ MetaLinkParser::~MetaLinkParser() }
void -MetaLinkParser::parse(string filename) +MetaLinkParser::parse(Pathname filename) +{ + parse(InputStream(filename)); +} + +void +MetaLinkParser::parse(const InputStream &is) { char buf[4096]; - std::ifstream is(filename.c_str()); - if (!is) + if (!is.stream()) ZYPP_THROW(Exception("MetaLinkParser: no such file")); - while (is.good()) + while (is.stream().good()) { - is.read(buf, sizeof(buf)); - parseBytes(buf, is.gcount()); + is.stream().read(buf, sizeof(buf)); + parseBytes(buf, is.stream().gcount()); } parseEnd(); } diff --git a/zypp/media/MetaLinkParser.h b/zypp/media/MetaLinkParser.h index eacc486..b9073d0 100644 --- a/zypp/media/MetaLinkParser.h +++ b/zypp/media/MetaLinkParser.h @@ -16,6 +16,7 @@
#include "zypp/base/Exception.h" #include "zypp/base/NonCopyable.h" +#include "zypp/base/InputStream.h" #include "zypp/media/MediaBlockList.h" #include "zypp/Url.h"
@@ -33,7 +34,13 @@ public: * parse a file consisting of metalink xml data * \throws Exception **/ - void parse(std::string filename); + void parse(Pathname filename); +
Why there is not parse with InputStream variant in header? I think it could be useful, as it allows to parse stream e.g. directly from network. Josef
It's included (don't know how it got lost in the email) Here the complete diff: http://gitorious.org/opensuse/libzypp/commit/9775d0e85d999835e85e87678a4210e... -- Dominik Heidler Maxfeldstr. 5, D-90409 Nuernberg, Germany SUSE LINUX Products GmbH, Nuernberg _________________________________________ ドミニク -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Dominik Heidler write:
Josef Reidinger write:
Dominik Heidler write:
diff --git a/zypp/media/MetaLinkParser.cc b/zypp/media/MetaLinkParser.cc index 056a7f5..2c11cf6 100644 --- a/zypp/media/MetaLinkParser.cc +++ b/zypp/media/MetaLinkParser.cc @@ -386,16 +386,21 @@ MetaLinkParser::~MetaLinkParser() }
void -MetaLinkParser::parse(string filename) +MetaLinkParser::parse(Pathname filename) +{ + parse(InputStream(filename)); +} + +void +MetaLinkParser::parse(const InputStream &is) { char buf[4096]; - std::ifstream is(filename.c_str()); - if (!is) + if (!is.stream()) ZYPP_THROW(Exception("MetaLinkParser: no such file")); - while (is.good()) + while (is.stream().good()) { - is.read(buf, sizeof(buf)); - parseBytes(buf, is.gcount()); + is.stream().read(buf, sizeof(buf)); + parseBytes(buf, is.stream().gcount()); } parseEnd(); } diff --git a/zypp/media/MetaLinkParser.h b/zypp/media/MetaLinkParser.h index eacc486..b9073d0 100644 --- a/zypp/media/MetaLinkParser.h +++ b/zypp/media/MetaLinkParser.h @@ -16,6 +16,7 @@
#include "zypp/base/Exception.h" #include "zypp/base/NonCopyable.h" +#include "zypp/base/InputStream.h" #include "zypp/media/MediaBlockList.h" #include "zypp/Url.h"
@@ -33,7 +34,13 @@ public: * parse a file consisting of metalink xml data * \throws Exception **/ - void parse(std::string filename); + void parse(Pathname filename); +
Why there is not parse with InputStream variant in header? I think it could be useful, as it allows to parse stream e.g. directly from network. Josef
It's included (don't know how it got lost in the email) Here the complete diff: http://gitorious.org/opensuse/libzypp/commit/9775d0e85d999835e85e87678a4210e...
Ah good. I add small hint there -- Josef Reidinger YaST team maintainer of perl-Bootloader and parts of webyast -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (2)
-
Dominik Heidler
-
Josef Reidinger