Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Web_Crawler / Iterators.h
bloba799f97f286377b5f617384f22f8d0a5f0065fd8
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Iterators.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //=============================================================================
12 #ifndef _ITERATORS_H
13 #define _ITERATORS_H
15 #include "URL.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 /**
22 * @class URL_Iterator
24 * @brief An abstract base class that defines an iterator.
26 * Subclasses of this base class can define what strings
27 * to return from <next>. This class decouples higher-level
28 * software from the details of whatever type of URL header or
29 * body we're iterating over.
31 class URL_Iterator
33 public:
34 /// "virtual" destructor.
35 virtual int destroy ();
37 // = Iterator methods.
38 /// Pass back the next <string> that hasn't been seen yet. Returns 0
39 /// when all items have been seen, else 1.
40 virtual int next (ACE_CString &string) = 0;
42 protected:
43 /// C++ destructor.
44 virtual ~URL_Iterator ();
47 /**
48 * @class HTML_Body_Iterator
50 * @brief An iterator that returns URLs embedded in HTML files.
52 class HTML_Body_Iterator : public URL_Iterator
54 public:
55 /// Constructor.
56 HTML_Body_Iterator (URL &url);
58 // = Iterator methods.
59 /**
60 * Pass back the next <url> that hasn't been seen in the
61 * memory-mapped file. Returns 0 when all items have been seen,
62 * else 1.
64 virtual int next (ACE_CString &url);
66 private:
67 /// HTTP URL that we're iterating over.
68 URL &url_;
71 /**
72 * @class HTTP_Header_Iterator
74 * @brief An iterator that iterates over the HTTP header.
76 class HTTP_Header_Iterator : public URL_Iterator
78 public:
79 /// Constructor.
80 HTTP_Header_Iterator (URL &url);
82 // = Iterator methods.
83 /**
84 * Pass back the next <line> that hasn't been seen in the
85 * memory-mapped file header. Returns 0 when we've reached the end
86 * of the header. seen, else 1.
88 virtual int next (ACE_CString &line);
90 private:
91 /// HTTP URL that we're iterating over.
92 URL &url_;
94 /// We've found the end of the header, which means this iterator is
95 /// finished.
96 int end_of_header_;
99 /**
100 * @class URL_Download_Iterator
102 * @brief An iterator that iterates over the contents of an entire URL,
103 * i.e., both header and body, and returns it in <BUFSIZ>
104 * <buffer>s.
106 class URL_Download_Iterator : public URL_Iterator
108 public:
109 /// Constructor.
110 URL_Download_Iterator (URL &url);
112 // = Iterator methods.
114 * Pass back the next <buffer> data from the stream, where
115 * <buffer.size> <= <BUFSIZ> . Returns 0 when we've reached the end
116 * of the header, else 1.
118 virtual int next (ACE_CString &buffer);
120 private:
121 /// HTTP URL that we're iterating over.
122 URL &url_;
125 #endif /* _ITERATORS_H */