1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/parser/susetags/ContentFileReader.h
12 #ifndef ZYPP_PARSER_SUSETAGS_CONTENTFILEREADER_H
13 #define ZYPP_PARSER_SUSETAGS_CONTENTFILEREADER_H
17 #include "zypp/base/PtrTypes.h"
18 #include "zypp/base/NonCopyable.h"
19 #include "zypp/base/Function.h"
20 #include "zypp/base/InputStream.h"
22 #include "zypp/ProgressData.h"
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
33 { /////////////////////////////////////////////////////////////////
36 DEFINE_PTR_TYPE(RepoIndex);
38 ///////////////////////////////////////////////////////////////////
40 // CLASS NAME : ContentFileReader
42 /** Parse repoindex part from a \c content file.
43 * This is all the downloader needs.
45 class ContentFileReader : private base::NonCopyable
48 typedef function<void(const RepoIndex_Ptr &)> RepoIndexConsumer;
54 virtual ~ContentFileReader();
56 * \throw ParseException on errors.
57 * \throw AbortRequestException on user request.
58 * Invokes \ref consume for each tag. \ref consume might throw
59 * other exceptions as well.
61 virtual void parse( const InputStream & imput_r,
62 const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() );
65 /** Consumer to call when repo index was parsed. */
66 void setRepoIndexConsumer( const RepoIndexConsumer & fnc_r )
67 { _repoIndexConsumer = fnc_r; }
70 /** Called when start parsing. */
71 virtual void beginParse();
72 /** Called when the parse is done. */
73 virtual void endParse();
76 /** Called when user(callback) request to abort.
77 * \throws AbortRequestException unless overloaded.
79 virtual void userRequestedAbort( unsigned lineNo_r );
82 /** Prefix exception message with line information. */
83 std::string errPrefix( unsigned lineNo_r,
84 const std::string & msg_r = std::string(),
85 const std::string & line_r = "-" ) const;
89 RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
90 RepoIndexConsumer _repoIndexConsumer;
92 ///////////////////////////////////////////////////////////////////
94 /////////////////////////////////////////////////////////////////
95 } // namespace susetags
96 ///////////////////////////////////////////////////////////////////
97 /////////////////////////////////////////////////////////////////
99 ///////////////////////////////////////////////////////////////////
100 /////////////////////////////////////////////////////////////////
102 ///////////////////////////////////////////////////////////////////
103 #endif // ZYPP_PARSER_SUSETAGS_CONTENTFILEREADER_H