Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Article.h

Go to the documentation of this file.
00001 #ifndef __Article_h__
00002 #define __Article_h__
00003 
00004 //#include <ctype.h>
00005 //#include <stdio.h>
00006 
00007 #include <string>
00008 
00009 #include "NSError.h"
00010 #include "Debug.h"
00011 #include "readline.h"
00012 
00018 class InvalidArticleError:public NSError {
00019       public:
00020         InvalidArticleError(const char *txt, const char *file,
00021                             const char *function, int line);
00022         
00023         InvalidArticleError(const std::string & txt, const char *file,
00024                               const char *function, int line);
00025 
00026         virtual void print(void);
00027 };
00028 
00036 class Article {
00037       private:
00038 
00044         const char *find_field(const char *ifld) const;
00045 
00046       protected:
00047         int _nbr;
00048         std::string _text;
00049         const char *_ctext;
00050 
00051       public:
00052         enum {
00053                 Head = 0x1,
00054                 Body = 0x2
00055         };
00056 
00057         Article();
00058         Article(Article * a);
00059         Article(int artnbr);
00060         Article(int artnbr, const char *text, int textlen = 0);
00061         ~Article();
00062 
00063         void read(std::istream & is);
00064 
00065         void setnbr(int nbr);
00066         
00067         void clear(void);
00068         
00069         void settext(const std::string & text);
00070 
00071         int getnbr(void) const;
00072         
00073         /* Return Text string
00074          */
00075         std::string GetText(void);
00076         
00077         const char *c_str(void);
00078         
00079         int length(void) const;
00080         
00081         int has_field(const char *ifld);
00082 
00083         /*
00084          * Return a header field of the article.
00085          * \param ifld The name of the field to be extracted including `:'
00086          * \throw NoSuchFieldError raised, if fld is not part of the
00087          *      overview database
00088          */
00089         std::string getfield(const char *ifld, int Full = 0) const;
00090 
00091         void setfield(const char *ifld, const char *field_data);
00092 
00093         std::ostream & write(std::ostream & os, int flags = Head | Body);
00094 
00095         friend std::ostream & operator<<(std::ostream & os, Article & art);
00096 };
00097 
00098 #endif

Generated on Fri Aug 20 10:58:06 2004 for NewsCache by doxygen 1.3.6-20040222