Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / protocols / ace / INet / FTP_Response.h
blob9b54236dd0882f5a0a543823aa68044b79990547
1 /**
2 * @file FTP_Response.h
4 * @author Martin Corino <mcorino@remedy.nl>
5 */
7 #ifndef ACE_FTP_RESPONSE_H
8 #define ACE_FTP_RESPONSE_H
10 #include /**/ "ace/pre.h"
12 #include "ace/INet/INet_Export.h"
13 #include "ace/INet/Response.h"
14 #include "ace/SString.h"
15 #include "ace/Containers_T.h"
16 #include <iostream>
18 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
20 namespace ACE
22 namespace FTP
24 /**
25 * @class ACE_FTP_Response
27 * @brief Encapsulates FTP responses.
30 class ACE_INET_Export Response
31 : public ACE::INet::Response
33 public:
34 Response ();
36 virtual ~Response ();
38 /// resets the FTP response
39 void reset ();
41 /// resets the FTP response and sets
42 /// the response status
43 Response& operator ()(int status);
45 /// returns the current response status
46 int status () const;
48 /// sets the current response status
49 void status (int status);
51 /// retrieves the current response line(s)
52 const ACE_Array<ACE_CString>& response () const;
54 /// adds a response line
55 Response& operator <<(const ACE_CString& line);
57 /// Writes the FTP response to the given stream
58 void write(std::ostream& str) const;
60 /// Reads the FTP response from the
61 /// given stream.
62 bool read(std::istream& str);
64 /// response types
65 enum StatusType
67 NOSTATE = -1,
68 NORESPONSE = 0,
69 PRELIM_OK = 1,
70 COMPLETED_OK = 2,
71 INTERMEDIATE_OK = 3,
72 TRANSIENT_FAIL = 4,
73 PERMANENT_FAIL = 5
76 /// response subtypes
77 enum StatusSubtype
79 NOSUBTYPE = -1,
80 SYNTAX = 0,
81 INFORMATION = 1,
82 CONNECTION = 2,
83 AUTHENTICATION = 3,
84 SUBTYPE_NONE = 4, // "NONE" conflicts with a macro on VxWorks.
85 FILESYSTEM = 5
88 /// returns the current response type
89 StatusType status_type () const;
91 /// returns true if the current response type is PRELIM_OK
92 bool is_preliminary_ok () const;
94 /// returns true if the current response type is COMPLETED_OK
95 bool is_completed_ok () const;
97 /// returns true if the current response type is INTERMEDIATE_OK
98 bool is_intermediate_ok () const;
100 /// returns true if the current response type is TRANSIENT_FAIL
101 bool is_transient_fail () const;
103 /// returns true if the current response type is PERMANENT_FAIL
104 bool is_permanent_fail () const;
106 /// returns the current response sub type
107 StatusSubtype status_sub_type () const;
109 static StatusType status_type (int status);
111 private:
112 static const int eof_;
114 int read_line (std::istream& is, std::ostream& os);
116 int status_;
117 ACE_Array<ACE_CString> response_;
122 ACE_END_VERSIONED_NAMESPACE_DECL
124 #if defined (__ACE_INLINE__)
125 #include "ace/INet/FTP_Response.inl"
126 #endif
128 #include /**/ "ace/post.h"
129 #endif /* ACE_FTP_RESPONSE_H */