diff options
Diffstat (limited to 'vmime')
100 files changed, 957 insertions, 832 deletions
diff --git a/vmime/address.hpp b/vmime/address.hpp index 110e1e6b..5eb510f9 100644 --- a/vmime/address.hpp +++ b/vmime/address.hpp @@ -76,8 +76,8 @@ public: */ static shared_ptr <address> parseNext (const parsingContext& ctx, const string& buffer, - const string::size_type position, const string::size_type end, - string::size_type* newPosition, bool *isLastAddressOfGroup); + const size_t position, const size_t end, + size_t* newPosition, bool *isLastAddressOfGroup); }; diff --git a/vmime/addressList.hpp b/vmime/addressList.hpp index 2987b1ac..0df657d3 100644 --- a/vmime/addressList.hpp +++ b/vmime/addressList.hpp @@ -174,15 +174,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/base.hpp b/vmime/base.hpp index 36938cb7..f6515794 100644 --- a/vmime/base.hpp +++ b/vmime/base.hpp @@ -156,7 +156,7 @@ namespace vmime namespace lineLengthLimits { - extern VMIME_EXPORT const string::size_type infinite; + extern VMIME_EXPORT const size_t infinite; enum { @@ -168,7 +168,7 @@ namespace vmime // New line sequence to be used when folding header fields. extern VMIME_EXPORT const string NEW_LINE_SEQUENCE; - extern VMIME_EXPORT const string::size_type NEW_LINE_SEQUENCE_LENGTH; + extern VMIME_EXPORT const size_t NEW_LINE_SEQUENCE_LENGTH; // CR-LF sequence @@ -182,6 +182,12 @@ namespace vmime namespace utility { } + /** Constant value with the greatest possible value for an element + * of type size_t. The meaning is "infinite" or "until the end". + */ + extern VMIME_EXPORT const size_t npos; + + /** Clone helper (using a shared_ptr). * This is an alias for dynamic_pointer_cast <T>(obj->clone()). */ diff --git a/vmime/body.hpp b/vmime/body.hpp index 465a7a81..e47f97e9 100644 --- a/vmime/body.hpp +++ b/vmime/body.hpp @@ -280,7 +280,7 @@ public: const std::vector <shared_ptr <component> > getChildComponents(); - utility::stream::size_type getGeneratedSize(const generationContext& ctx); + size_t getGeneratedSize(const generationContext& ctx); private: @@ -315,26 +315,26 @@ protected: * CR/LF and "--" before the boundary) * @param boundaryEnd will hold the end position of the boundary (position just * before the CRLF or "--" which follows) - * @return the position of the boundary string, or stream::npos if not found + * @return the position of the boundary string, or npos if not found */ - utility::stream::size_type findNextBoundaryPosition + size_t findNextBoundaryPosition (shared_ptr <utility::parserInputStreamAdapter> parser, const string& boundary, - const utility::stream::size_type position, const utility::stream::size_type end, - utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd); + const size_t position, const size_t end, + size_t* boundaryStart, size_t* boundaryEnd); // Component parsing & assembling void parseImpl (const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser, - const utility::stream::size_type position, - const utility::stream::size_type end, - utility::stream::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp index fd0deb73..214cb208 100644 --- a/vmime/bodyPart.hpp +++ b/vmime/bodyPart.hpp @@ -102,7 +102,7 @@ public: const std::vector <shared_ptr <component> > getChildComponents(); - utility::stream::size_type getGeneratedSize(const generationContext& ctx); + size_t getGeneratedSize(const generationContext& ctx); private: @@ -137,15 +137,15 @@ protected: void parseImpl (const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser, - const utility::stream::size_type position, - const utility::stream::size_type end, - utility::stream::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/charset.hpp b/vmime/charset.hpp index 9c1325c6..5bd50fdf 100644 --- a/vmime/charset.hpp +++ b/vmime/charset.hpp @@ -130,15 +130,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/charsetConverter_iconv.hpp b/vmime/charsetConverter_iconv.hpp index 0309d848..4167dc4e 100644 --- a/vmime/charsetConverter_iconv.hpp +++ b/vmime/charsetConverter_iconv.hpp @@ -93,9 +93,12 @@ public: outputStream& getNextOutputStream(); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: // Maximum character width in any charset @@ -112,12 +115,12 @@ private: // Buffer in which unconverted bytes are left until they can // be converted (when more data arrives). The length should be // large enough to contain any character in any charset. - value_type m_unconvBuffer[MAX_CHARACTER_WIDTH]; - size_type m_unconvCount; + byte_t m_unconvBuffer[MAX_CHARACTER_WIDTH]; + size_t m_unconvCount; // Buffer used for conversion. Avoids declaring it in write(). // Should be at least MAX_CHARACTER_WIDTH * MAX_CHARACTER_WIDTH. - value_type m_outputBuffer[32768]; + byte_t m_outputBuffer[32768]; }; diff --git a/vmime/charsetConverter_icu.hpp b/vmime/charsetConverter_icu.hpp index 91cf0b86..5d054413 100644 --- a/vmime/charsetConverter_icu.hpp +++ b/vmime/charsetConverter_icu.hpp @@ -97,9 +97,12 @@ public: outputStream& getNextOutputStream();
- void write(const value_type* const data, const size_type count);
void flush();
+protected:
+
+ void writeImpl(const byte_t* const data, const size_t count);
+
private:
UConverter* m_from;
diff --git a/vmime/component.hpp b/vmime/component.hpp index 0c3716cb..87d465e8 100644 --- a/vmime/component.hpp +++ b/vmime/component.hpp @@ -70,7 +70,7 @@ public: * @param inputStream stream from which to read data * @param length data length, in bytes (0 = unknown/not specified) */ - void parse(shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type length); + void parse(shared_ptr <utility::inputStream> inputStream, const size_t length); /** Parse RFC-822/MIME data for this component, using the default * parsing context. @@ -82,9 +82,9 @@ public: */ void parse (const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); /** Parse RFC-822/MIME data for this component. * @@ -97,9 +97,9 @@ public: void parse (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); /** Parse RFC-822/MIME data for this component. If stream is not seekable, * or if end position is not specified, entire contents of the stream will @@ -113,9 +113,9 @@ public: */ void parse (shared_ptr <utility::inputStream> inputStream, - const utility::stream::size_type position, - const utility::stream::size_type end, - utility::stream::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); /** Parse RFC-822/MIME data for this component. If stream is not seekable, * or if end position is not specified, entire contents of the stream will @@ -130,9 +130,9 @@ public: void parse (const parsingContext& ctx, shared_ptr <utility::inputStream> inputStream, - const utility::stream::size_type position, - const utility::stream::size_type end, - utility::stream::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); /** Generate RFC-2822/MIME data for this component. * @@ -143,8 +143,8 @@ public: * @return generated data */ virtual const string generate - (const string::size_type maxLineLength = lineLengthLimits::infinite, - const string::size_type curLinePos = 0) const; + (const size_t maxLineLength = lineLengthLimits::infinite, + const size_t curLinePos = 0) const; /** Generate RFC-2822/MIME data for this component, using the default generation context. * @@ -154,8 +154,8 @@ public: */ virtual void generate (utility::outputStream& outputStream, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; /** Generate RFC-2822/MIME data for this component, using the default generation context. * @@ -167,8 +167,8 @@ public: virtual void generate (const generationContext& ctx, utility::outputStream& outputStream, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; /** Clone this component. * @@ -191,7 +191,7 @@ public: * @return start position in parsed buffer * or 0 if this component has not been parsed */ - utility::stream::size_type getParsedOffset() const; + size_t getParsedOffset() const; /** Return the length of this component in the * parsed message contents. Use for debugging only. @@ -199,7 +199,7 @@ public: * @return length of the component in parsed buffer * or 0 if this component has not been parsed */ - utility::stream::size_type getParsedLength() const; + size_t getParsedLength() const; /** Return the list of children of this component. * @@ -215,39 +215,39 @@ public: * @param ctx generation context * @return component size when generated */ - virtual utility::stream::size_type getGeneratedSize(const generationContext& ctx); + virtual size_t getGeneratedSize(const generationContext& ctx); protected: - void setParsedBounds(const utility::stream::size_type start, const utility::stream::size_type end); + void setParsedBounds(const size_t start, const size_t end); // AT LEAST ONE of these parseImpl() functions MUST be implemented in derived class virtual void parseImpl (const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser, - const utility::stream::size_type position, - const utility::stream::size_type end, - utility::stream::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); virtual void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); virtual void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const = 0; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const = 0; private: - void offsetParsedBounds(const utility::stream::size_type offset); + void offsetParsedBounds(const size_t offset); - utility::stream::size_type m_parsedOffset; - utility::stream::size_type m_parsedLength; + size_t m_parsedOffset; + size_t m_parsedLength; }; diff --git a/vmime/constants.hpp b/vmime/constants.hpp index b4747f60..8e6e3f83 100644 --- a/vmime/constants.hpp +++ b/vmime/constants.hpp @@ -43,173 +43,173 @@ namespace vmime namespace mediaTypes { // Types - extern VMIME_EXPORT const string::value_type* const TEXT; - extern VMIME_EXPORT const string::value_type* const MULTIPART; - extern VMIME_EXPORT const string::value_type* const MESSAGE; - extern VMIME_EXPORT const string::value_type* const APPLICATION; - extern VMIME_EXPORT const string::value_type* const IMAGE; - extern VMIME_EXPORT const string::value_type* const AUDIO; - extern VMIME_EXPORT const string::value_type* const VIDEO; + extern VMIME_EXPORT const char* const TEXT; + extern VMIME_EXPORT const char* const MULTIPART; + extern VMIME_EXPORT const char* const MESSAGE; + extern VMIME_EXPORT const char* const APPLICATION; + extern VMIME_EXPORT const char* const IMAGE; + extern VMIME_EXPORT const char* const AUDIO; + extern VMIME_EXPORT const char* const VIDEO; // Sub-types - extern VMIME_EXPORT const string::value_type* const TEXT_PLAIN; - extern VMIME_EXPORT const string::value_type* const TEXT_HTML; - extern VMIME_EXPORT const string::value_type* const TEXT_RICHTEXT; - extern VMIME_EXPORT const string::value_type* const TEXT_ENRICHED; - extern VMIME_EXPORT const string::value_type* const TEXT_RFC822_HEADERS; // RFC-1892 - extern VMIME_EXPORT const string::value_type* const TEXT_DIRECTORY; // RFC-2426 + extern VMIME_EXPORT const char* const TEXT_PLAIN; + extern VMIME_EXPORT const char* const TEXT_HTML; + extern VMIME_EXPORT const char* const TEXT_RICHTEXT; + extern VMIME_EXPORT const char* const TEXT_ENRICHED; + extern VMIME_EXPORT const char* const TEXT_RFC822_HEADERS; // RFC-1892 + extern VMIME_EXPORT const char* const TEXT_DIRECTORY; // RFC-2426 - extern VMIME_EXPORT const string::value_type* const MULTIPART_MIXED; - extern VMIME_EXPORT const string::value_type* const MULTIPART_RELATED; - extern VMIME_EXPORT const string::value_type* const MULTIPART_ALTERNATIVE; - extern VMIME_EXPORT const string::value_type* const MULTIPART_PARALLEL; - extern VMIME_EXPORT const string::value_type* const MULTIPART_DIGEST; - extern VMIME_EXPORT const string::value_type* const MULTIPART_REPORT; // RFC-1892 + extern VMIME_EXPORT const char* const MULTIPART_MIXED; + extern VMIME_EXPORT const char* const MULTIPART_RELATED; + extern VMIME_EXPORT const char* const MULTIPART_ALTERNATIVE; + extern VMIME_EXPORT const char* const MULTIPART_PARALLEL; + extern VMIME_EXPORT const char* const MULTIPART_DIGEST; + extern VMIME_EXPORT const char* const MULTIPART_REPORT; // RFC-1892 - extern VMIME_EXPORT const string::value_type* const MESSAGE_RFC822; - extern VMIME_EXPORT const string::value_type* const MESSAGE_PARTIAL; - extern VMIME_EXPORT const string::value_type* const MESSAGE_EXTERNAL_BODY; - extern VMIME_EXPORT const string::value_type* const MESSAGE_DISPOSITION_NOTIFICATION; + extern VMIME_EXPORT const char* const MESSAGE_RFC822; + extern VMIME_EXPORT const char* const MESSAGE_PARTIAL; + extern VMIME_EXPORT const char* const MESSAGE_EXTERNAL_BODY; + extern VMIME_EXPORT const char* const MESSAGE_DISPOSITION_NOTIFICATION; - extern VMIME_EXPORT const string::value_type* const APPLICATION_OCTET_STREAM; + extern VMIME_EXPORT const char* const APPLICATION_OCTET_STREAM; - extern VMIME_EXPORT const string::value_type* const IMAGE_JPEG; - extern VMIME_EXPORT const string::value_type* const IMAGE_GIF; + extern VMIME_EXPORT const char* const IMAGE_JPEG; + extern VMIME_EXPORT const char* const IMAGE_GIF; - extern VMIME_EXPORT const string::value_type* const AUDIO_BASIC; + extern VMIME_EXPORT const char* const AUDIO_BASIC; - extern VMIME_EXPORT const string::value_type* const VIDEO_MPEG; + extern VMIME_EXPORT const char* const VIDEO_MPEG; } /** Constants for encoding types. */ namespace encodingTypes { - extern VMIME_EXPORT const string::value_type* const SEVEN_BIT; - extern VMIME_EXPORT const string::value_type* const EIGHT_BIT; - extern VMIME_EXPORT const string::value_type* const BASE64; - extern VMIME_EXPORT const string::value_type* const QUOTED_PRINTABLE; - extern VMIME_EXPORT const string::value_type* const BINARY; - extern VMIME_EXPORT const string::value_type* const UUENCODE; + extern VMIME_EXPORT const char* const SEVEN_BIT; + extern VMIME_EXPORT const char* const EIGHT_BIT; + extern VMIME_EXPORT const char* const BASE64; + extern VMIME_EXPORT const char* const QUOTED_PRINTABLE; + extern VMIME_EXPORT const char* const BINARY; + extern VMIME_EXPORT const char* const UUENCODE; } /** Constants for content disposition types (RFC-2183). */ namespace contentDispositionTypes { - extern VMIME_EXPORT const string::value_type* const INLINE; - extern VMIME_EXPORT const string::value_type* const ATTACHMENT; + extern VMIME_EXPORT const char* const INLINE; + extern VMIME_EXPORT const char* const ATTACHMENT; } /** Constants for charsets. */ namespace charsets { - extern VMIME_EXPORT const string::value_type* const ISO8859_1; - extern VMIME_EXPORT const string::value_type* const ISO8859_2; - extern VMIME_EXPORT const string::value_type* const ISO8859_3; - extern VMIME_EXPORT const string::value_type* const ISO8859_4; - extern VMIME_EXPORT const string::value_type* const ISO8859_5; - extern VMIME_EXPORT const string::value_type* const ISO8859_6; - extern VMIME_EXPORT const string::value_type* const ISO8859_7; - extern VMIME_EXPORT const string::value_type* const ISO8859_8; - extern VMIME_EXPORT const string::value_type* const ISO8859_9; - extern VMIME_EXPORT const string::value_type* const ISO8859_10; - extern VMIME_EXPORT const string::value_type* const ISO8859_13; - extern VMIME_EXPORT const string::value_type* const ISO8859_14; - extern VMIME_EXPORT const string::value_type* const ISO8859_15; - extern VMIME_EXPORT const string::value_type* const ISO8859_16; - - extern VMIME_EXPORT const string::value_type* const CP_437; - extern VMIME_EXPORT const string::value_type* const CP_737; - extern VMIME_EXPORT const string::value_type* const CP_775; - extern VMIME_EXPORT const string::value_type* const CP_850; - extern VMIME_EXPORT const string::value_type* const CP_852; - extern VMIME_EXPORT const string::value_type* const CP_853; - extern VMIME_EXPORT const string::value_type* const CP_855; - extern VMIME_EXPORT const string::value_type* const CP_857; - extern VMIME_EXPORT const string::value_type* const CP_858; - extern VMIME_EXPORT const string::value_type* const CP_860; - extern VMIME_EXPORT const string::value_type* const CP_861; - extern VMIME_EXPORT const string::value_type* const CP_862; - extern VMIME_EXPORT const string::value_type* const CP_863; - extern VMIME_EXPORT const string::value_type* const CP_864; - extern VMIME_EXPORT const string::value_type* const CP_865; - extern VMIME_EXPORT const string::value_type* const CP_866; - extern VMIME_EXPORT const string::value_type* const CP_869; - extern VMIME_EXPORT const string::value_type* const CP_874; - extern VMIME_EXPORT const string::value_type* const CP_1125; - extern VMIME_EXPORT const string::value_type* const CP_1250; - extern VMIME_EXPORT const string::value_type* const CP_1251; - extern VMIME_EXPORT const string::value_type* const CP_1252; - extern VMIME_EXPORT const string::value_type* const CP_1253; - extern VMIME_EXPORT const string::value_type* const CP_1254; - extern VMIME_EXPORT const string::value_type* const CP_1255; - extern VMIME_EXPORT const string::value_type* const CP_1256; - extern VMIME_EXPORT const string::value_type* const CP_1257; - - extern VMIME_EXPORT const string::value_type* const US_ASCII; - - extern VMIME_EXPORT const string::value_type* const UTF_7; - extern VMIME_EXPORT const string::value_type* const UTF_8; - extern VMIME_EXPORT const string::value_type* const UTF_16; - extern VMIME_EXPORT const string::value_type* const UTF_32; - - extern VMIME_EXPORT const string::value_type* const WINDOWS_1250; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1251; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1252; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1253; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1254; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1255; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1256; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1257; - extern VMIME_EXPORT const string::value_type* const WINDOWS_1258; - - extern VMIME_EXPORT const string::value_type* const IDNA; + extern VMIME_EXPORT const char* const ISO8859_1; + extern VMIME_EXPORT const char* const ISO8859_2; + extern VMIME_EXPORT const char* const ISO8859_3; + extern VMIME_EXPORT const char* const ISO8859_4; + extern VMIME_EXPORT const char* const ISO8859_5; + extern VMIME_EXPORT const char* const ISO8859_6; + extern VMIME_EXPORT const char* const ISO8859_7; + extern VMIME_EXPORT const char* const ISO8859_8; + extern VMIME_EXPORT const char* const ISO8859_9; + extern VMIME_EXPORT const char* const ISO8859_10; + extern VMIME_EXPORT const char* const ISO8859_13; + extern VMIME_EXPORT const char* const ISO8859_14; + extern VMIME_EXPORT const char* const ISO8859_15; + extern VMIME_EXPORT const char* const ISO8859_16; + + extern VMIME_EXPORT const char* const CP_437; + extern VMIME_EXPORT const char* const CP_737; + extern VMIME_EXPORT const char* const CP_775; + extern VMIME_EXPORT const char* const CP_850; + extern VMIME_EXPORT const char* const CP_852; + extern VMIME_EXPORT const char* const CP_853; + extern VMIME_EXPORT const char* const CP_855; + extern VMIME_EXPORT const char* const CP_857; + extern VMIME_EXPORT const char* const CP_858; + extern VMIME_EXPORT const char* const CP_860; + extern VMIME_EXPORT const char* const CP_861; + extern VMIME_EXPORT const char* const CP_862; + extern VMIME_EXPORT const char* const CP_863; + extern VMIME_EXPORT const char* const CP_864; + extern VMIME_EXPORT const char* const CP_865; + extern VMIME_EXPORT const char* const CP_866; + extern VMIME_EXPORT const char* const CP_869; + extern VMIME_EXPORT const char* const CP_874; + extern VMIME_EXPORT const char* const CP_1125; + extern VMIME_EXPORT const char* const CP_1250; + extern VMIME_EXPORT const char* const CP_1251; + extern VMIME_EXPORT const char* const CP_1252; + extern VMIME_EXPORT const char* const CP_1253; + extern VMIME_EXPORT const char* const CP_1254; + extern VMIME_EXPORT const char* const CP_1255; + extern VMIME_EXPORT const char* const CP_1256; + extern VMIME_EXPORT const char* const CP_1257; + + extern VMIME_EXPORT const char* const US_ASCII; + + extern VMIME_EXPORT const char* const UTF_7; + extern VMIME_EXPORT const char* const UTF_8; + extern VMIME_EXPORT const char* const UTF_16; + extern VMIME_EXPORT const char* const UTF_32; + + extern VMIME_EXPORT const char* const WINDOWS_1250; + extern VMIME_EXPORT const char* const WINDOWS_1251; + extern VMIME_EXPORT const char* const WINDOWS_1252; + extern VMIME_EXPORT const char* const WINDOWS_1253; + extern VMIME_EXPORT const char* const WINDOWS_1254; + extern VMIME_EXPORT const char* const WINDOWS_1255; + extern VMIME_EXPORT const char* const WINDOWS_1256; + extern VMIME_EXPORT const char* const WINDOWS_1257; + extern VMIME_EXPORT const char* const WINDOWS_1258; + + extern VMIME_EXPORT const char* const IDNA; } /** Constants for standard field names. */ namespace fields { - extern VMIME_EXPORT const string::value_type* const RECEIVED; - extern VMIME_EXPORT const string::value_type* const FROM; - extern VMIME_EXPORT const string::value_type* const SENDER; - extern VMIME_EXPORT const string::value_type* const REPLY_TO; - extern VMIME_EXPORT const string::value_type* const TO; - extern VMIME_EXPORT const string::value_type* const CC; - extern VMIME_EXPORT const string::value_type* const BCC; - extern VMIME_EXPORT const string::value_type* const DATE; - extern VMIME_EXPORT const string::value_type* const SUBJECT; - extern VMIME_EXPORT const string::value_type* const ORGANIZATION; - extern VMIME_EXPORT const string::value_type* const USER_AGENT; - extern VMIME_EXPORT const string::value_type* const DELIVERED_TO; - extern VMIME_EXPORT const string::value_type* const RETURN_PATH; - extern VMIME_EXPORT const string::value_type* const MIME_VERSION; - extern VMIME_EXPORT const string::value_type* const MESSAGE_ID; - extern VMIME_EXPORT const string::value_type* const CONTENT_TYPE; - extern VMIME_EXPORT const string::value_type* const CONTENT_TRANSFER_ENCODING; - extern VMIME_EXPORT const string::value_type* const CONTENT_DESCRIPTION; - extern VMIME_EXPORT const string::value_type* const CONTENT_DISPOSITION; - extern VMIME_EXPORT const string::value_type* const CONTENT_ID; - extern VMIME_EXPORT const string::value_type* const CONTENT_LOCATION; - extern VMIME_EXPORT const string::value_type* const IN_REPLY_TO; - extern VMIME_EXPORT const string::value_type* const REFERENCES; - - extern VMIME_EXPORT const string::value_type* const X_MAILER; - extern VMIME_EXPORT const string::value_type* const X_PRIORITY; + extern VMIME_EXPORT const char* const RECEIVED; + extern VMIME_EXPORT const char* const FROM; + extern VMIME_EXPORT const char* const SENDER; + extern VMIME_EXPORT const char* const REPLY_TO; + extern VMIME_EXPORT const char* const TO; + extern VMIME_EXPORT const char* const CC; + extern VMIME_EXPORT const char* const BCC; + extern VMIME_EXPORT const char* const DATE; + extern VMIME_EXPORT const char* const SUBJECT; + extern VMIME_EXPORT const char* const ORGANIZATION; + extern VMIME_EXPORT const char* const USER_AGENT; + extern VMIME_EXPORT const char* const DELIVERED_TO; + extern VMIME_EXPORT const char* const RETURN_PATH; + extern VMIME_EXPORT const char* const MIME_VERSION; + extern VMIME_EXPORT const char* const MESSAGE_ID; + extern VMIME_EXPORT const char* const CONTENT_TYPE; + extern VMIME_EXPORT const char* const CONTENT_TRANSFER_ENCODING; + extern VMIME_EXPORT const char* const CONTENT_DESCRIPTION; + extern VMIME_EXPORT const char* const CONTENT_DISPOSITION; + extern VMIME_EXPORT const char* const CONTENT_ID; + extern VMIME_EXPORT const char* const CONTENT_LOCATION; + extern VMIME_EXPORT const char* const IN_REPLY_TO; + extern VMIME_EXPORT const char* const REFERENCES; + + extern VMIME_EXPORT const char* const X_MAILER; + extern VMIME_EXPORT const char* const X_PRIORITY; // RFC-3798: Message Disposition Notification - extern VMIME_EXPORT const string::value_type* const ORIGINAL_MESSAGE_ID; - extern VMIME_EXPORT const string::value_type* const DISPOSITION_NOTIFICATION_TO; - extern VMIME_EXPORT const string::value_type* const DISPOSITION_NOTIFICATION_OPTIONS; - extern VMIME_EXPORT const string::value_type* const DISPOSITION; - extern VMIME_EXPORT const string::value_type* const FAILURE; - extern VMIME_EXPORT const string::value_type* const ERROR; - extern VMIME_EXPORT const string::value_type* const WARNING; - extern VMIME_EXPORT const string::value_type* const ORIGINAL_RECIPIENT; - extern VMIME_EXPORT const string::value_type* const FINAL_RECIPIENT; - extern VMIME_EXPORT const string::value_type* const REPORTING_UA; - extern VMIME_EXPORT const string::value_type* const MDN_GATEWAY; + extern VMIME_EXPORT const char* const ORIGINAL_MESSAGE_ID; + extern VMIME_EXPORT const char* const DISPOSITION_NOTIFICATION_TO; + extern VMIME_EXPORT const char* const DISPOSITION_NOTIFICATION_OPTIONS; + extern VMIME_EXPORT const char* const DISPOSITION; + extern VMIME_EXPORT const char* const FAILURE; + extern VMIME_EXPORT const char* const ERROR; + extern VMIME_EXPORT const char* const WARNING; + extern VMIME_EXPORT const char* const ORIGINAL_RECIPIENT; + extern VMIME_EXPORT const char* const FINAL_RECIPIENT; + extern VMIME_EXPORT const char* const REPORTING_UA; + extern VMIME_EXPORT const char* const MDN_GATEWAY; } /** Constants for disposition action modes (RFC-3978). */ @@ -217,10 +217,10 @@ namespace vmime { /** User implicitely displayed or deleted the message (filter or * any other automatic action). */ - extern VMIME_EXPORT const string::value_type* const AUTOMATIC; + extern VMIME_EXPORT const char* const AUTOMATIC; /** User explicitely displayed or deleted the message (manual action). */ - extern VMIME_EXPORT const string::value_type* const MANUAL; + extern VMIME_EXPORT const char* const MANUAL; } /** Constants for disposition sending modes (RFC-3798). */ @@ -228,27 +228,27 @@ namespace vmime { /** The MDN was sent because the MUA had previously been configured * to do so automatically. */ - extern VMIME_EXPORT const string::value_type* const SENT_AUTOMATICALLY; + extern VMIME_EXPORT const char* const SENT_AUTOMATICALLY; /** User explicitly gave permission for this particular MDN to be sent. */ - extern VMIME_EXPORT const string::value_type* const SENT_MANUALLY; + extern VMIME_EXPORT const char* const SENT_MANUALLY; } /** Constants for disposition types (RFC-3798). */ namespace dispositionTypes { /** Message has been displayed to the user. */ - extern VMIME_EXPORT const string::value_type* const DISPLAYED; + extern VMIME_EXPORT const char* const DISPLAYED; /** Message has been deleted without being displayed. */ - extern VMIME_EXPORT const string::value_type* const DELETED; + extern VMIME_EXPORT const char* const DELETED; /** Message has been denied. */ - extern VMIME_EXPORT const string::value_type* const DENIED; + extern VMIME_EXPORT const char* const DENIED; } /** Constants for disposition modifiers (RFC-3798). */ namespace dispositionModifiers { - extern VMIME_EXPORT const string::value_type* const ERROR; + extern VMIME_EXPORT const char* const ERROR; } } diff --git a/vmime/contentDisposition.hpp b/vmime/contentDisposition.hpp index 0f417111..c934b81d 100644 --- a/vmime/contentDisposition.hpp +++ b/vmime/contentDisposition.hpp @@ -81,15 +81,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/contentHandler.hpp b/vmime/contentHandler.hpp index 5ae9e02b..f62af166 100644 --- a/vmime/contentHandler.hpp +++ b/vmime/contentHandler.hpp @@ -63,7 +63,7 @@ public: * @param enc encoding for output * @param maxLineLength maximum line length for output */ - virtual void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const = 0; + virtual void generate(utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength = lineLengthLimits::infinite) const = 0; /** Extract the contents into the specified stream. If needed, data * will be decoded before being written into the stream. @@ -92,7 +92,7 @@ public: * * @return length of data */ - virtual string::size_type getLength() const = 0; + virtual size_t getLength() const = 0; /** Returns 'true' if data managed by this object is encoded. * diff --git a/vmime/dateTime.hpp b/vmime/dateTime.hpp index 8a596f02..7af63040 100644 --- a/vmime/dateTime.hpp +++ b/vmime/dateTime.hpp @@ -245,15 +245,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/disposition.hpp b/vmime/disposition.hpp index 01de1653..7322c21d 100644 --- a/vmime/disposition.hpp +++ b/vmime/disposition.hpp @@ -140,15 +140,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/emailAddress.hpp b/vmime/emailAddress.hpp index e46afdf6..30ee24ab 100644 --- a/vmime/emailAddress.hpp +++ b/vmime/emailAddress.hpp @@ -117,15 +117,15 @@ public: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/emptyContentHandler.hpp b/vmime/emptyContentHandler.hpp index 1307f7eb..369a4206 100644 --- a/vmime/emptyContentHandler.hpp +++ b/vmime/emptyContentHandler.hpp @@ -40,12 +40,12 @@ public: shared_ptr <contentHandler> clone() const; - void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; + void generate(utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; - string::size_type getLength() const; + size_t getLength() const; bool isEncoded() const; diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp index ba07a25f..3148f899 100644 --- a/vmime/encoding.hpp +++ b/vmime/encoding.hpp @@ -154,15 +154,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/fileAttachment.hpp b/vmime/fileAttachment.hpp index 2d9ff575..1e7a808a 100644 --- a/vmime/fileAttachment.hpp +++ b/vmime/fileAttachment.hpp @@ -158,18 +158,18 @@ public: * * @return file size */ - utility::stream::size_type getSize() const; + size_t getSize() const; /** Set the value of the 'size' property. * * @param size file size */ - void setSize(const utility::stream::size_type size); + void setSize(const size_t size); private: word* m_filename; - utility::stream::size_type* m_size; + size_t * m_size; datetime* m_creationDate; datetime* m_modifDate; datetime* m_readDate; diff --git a/vmime/generationContext.hpp b/vmime/generationContext.hpp index 743ae6f5..949f06ac 100644 --- a/vmime/generationContext.hpp +++ b/vmime/generationContext.hpp @@ -46,7 +46,7 @@ public: * * @return current maximum line length, in bytes */ - string::size_type getMaxLineLength() const; + size_t getMaxLineLength() const; /** Sets the maximum line length used when generating messages. * You may use the constants lineLengthLimits::convenient, @@ -54,7 +54,7 @@ public: * * @param maxLineLength new maximum line length, in bytes */ - void setMaxLineLength(const string::size_type maxLineLength); + void setMaxLineLength(const size_t maxLineLength); /** Returns the current prolog text used when generating MIME body parts. * @@ -93,7 +93,7 @@ public: protected: - string::size_type m_maxLineLength; + size_t m_maxLineLength; string m_prologText; string m_epilogText; diff --git a/vmime/header.hpp b/vmime/header.hpp index 4490e5d6..d2d20727 100644 --- a/vmime/header.hpp +++ b/vmime/header.hpp @@ -291,7 +291,7 @@ public: const std::vector <shared_ptr <component> > getChildComponents(); - utility::stream::size_type getGeneratedSize(const generationContext& ctx); + size_t getGeneratedSize(const generationContext& ctx); private: @@ -328,15 +328,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/headerField.hpp b/vmime/headerField.hpp index c9972317..555805db 100644 --- a/vmime/headerField.hpp +++ b/vmime/headerField.hpp @@ -157,26 +157,26 @@ public: static shared_ptr <headerField> parseNext (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); - utility::stream::size_type getGeneratedSize(const generationContext& ctx); + size_t getGeneratedSize(const generationContext& ctx); protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; string m_name; diff --git a/vmime/headerFieldValue.hpp b/vmime/headerFieldValue.hpp index 2a04a823..a3681953 100644 --- a/vmime/headerFieldValue.hpp +++ b/vmime/headerFieldValue.hpp @@ -41,7 +41,7 @@ class VMIME_EXPORT headerFieldValue : public component { public: - utility::stream::size_type getGeneratedSize(const generationContext& ctx); + size_t getGeneratedSize(const generationContext& ctx); }; diff --git a/vmime/mailbox.hpp b/vmime/mailbox.hpp index 586f88ee..88abc0f5 100644 --- a/vmime/mailbox.hpp +++ b/vmime/mailbox.hpp @@ -105,15 +105,15 @@ public: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/mailboxField.hpp b/vmime/mailboxField.hpp index 75cae592..ca6863c0 100644 --- a/vmime/mailboxField.hpp +++ b/vmime/mailboxField.hpp @@ -53,8 +53,8 @@ protected: public: void parse(const parsingContext& ctx, const string& buffer, - const string::size_type position, const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, const size_t end, + size_t * newPosition = NULL); }; diff --git a/vmime/mailboxGroup.hpp b/vmime/mailboxGroup.hpp index a85c0232..b264cf60 100644 --- a/vmime/mailboxGroup.hpp +++ b/vmime/mailboxGroup.hpp @@ -176,15 +176,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/mailboxList.hpp b/vmime/mailboxList.hpp index 4003b680..125c238e 100644 --- a/vmime/mailboxList.hpp +++ b/vmime/mailboxList.hpp @@ -166,15 +166,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/mediaType.hpp b/vmime/mediaType.hpp index c2b214bd..a7d6f4e4 100644 --- a/vmime/mediaType.hpp +++ b/vmime/mediaType.hpp @@ -101,15 +101,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/message.hpp b/vmime/message.hpp index 22523efc..62ff77e1 100644 --- a/vmime/message.hpp +++ b/vmime/message.hpp @@ -50,8 +50,8 @@ public: // Override default generate() functions so that we can change // the default 'maxLineLength' value const string generate - (const string::size_type maxLineLength = generationContext::getDefaultContext().getMaxLineLength(), - const string::size_type curLinePos = 0) const; + (const size_t maxLineLength = generationContext::getDefaultContext().getMaxLineLength(), + const size_t curLinePos = 0) const; }; diff --git a/vmime/messageId.hpp b/vmime/messageId.hpp index 8c2f85d1..83527468 100644 --- a/vmime/messageId.hpp +++ b/vmime/messageId.hpp @@ -110,15 +110,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; /** Parse a message-id from an input buffer. * @@ -131,9 +131,9 @@ protected: static shared_ptr <messageId> parseNext (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition); + const size_t position, + const size_t end, + size_t* newPosition); }; diff --git a/vmime/messageIdSequence.hpp b/vmime/messageIdSequence.hpp index 39c415c7..07f0c422 100644 --- a/vmime/messageIdSequence.hpp +++ b/vmime/messageIdSequence.hpp @@ -154,15 +154,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp index deefaf49..38ba4597 100644 --- a/vmime/net/folder.hpp +++ b/vmime/net/folder.hpp @@ -282,7 +282,7 @@ public: * @param progress progress listener, or NULL if not used * @throw exceptions::net_exception if an error occurs */ - virtual void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; + virtual void addMessage(utility::inputStream& is, const size_t size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; /** Copy messages from this folder to another folder. * diff --git a/vmime/net/imap/IMAPConnection.hpp b/vmime/net/imap/IMAPConnection.hpp index bc5590ba..b38d0c27 100644 --- a/vmime/net/imap/IMAPConnection.hpp +++ b/vmime/net/imap/IMAPConnection.hpp @@ -80,7 +80,7 @@ public: void send(bool tag, const string& what, bool end); - void sendRaw(const char* buffer, const int count); + void sendRaw(const byte_t* buffer, const size_t count); IMAPParser::response* readResponse(IMAPParser::literalHandler* lh = NULL); diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp index 5edbfb16..cc7334ff 100644 --- a/vmime/net/imap/IMAPFolder.hpp +++ b/vmime/net/imap/IMAPFolder.hpp @@ -106,7 +106,7 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); - void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + void addMessage(utility::inputStream& is, const size_t size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessages(const folder::path& dest, const messageSet& msgs); diff --git a/vmime/net/imap/IMAPMessage.hpp b/vmime/net/imap/IMAPMessage.hpp index 272fe17b..92903d69 100644 --- a/vmime/net/imap/IMAPMessage.hpp +++ b/vmime/net/imap/IMAPMessage.hpp @@ -80,7 +80,7 @@ public: */ vmime_uint64 getModSequence() const; - int getSize() const; + size_t getSize() const; bool isExpunged() const; @@ -92,8 +92,18 @@ public: int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); - void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; + void extract + (utility::outputStream& os, + utility::progressListener* progress = NULL, + const size_t start = 0, const size_t length = -1, + const bool peek = false) const; + + void extractPart + (shared_ptr <const messagePart> p, + utility::outputStream& os, + utility::progressListener* progress = NULL, + const size_t start = 0, const size_t length = -1, + const bool peek = false) const; void fetchPartHeader(shared_ptr <messagePart> p); @@ -144,8 +154,12 @@ private: EXTRACT_PEEK = 0x10 }; - void extractImpl(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress, - const int start, const int length, const int extractFlags) const; + void extractImpl + (shared_ptr <const messagePart> p, + utility::outputStream& os, + utility::progressListener* progress, + const size_t start, const size_t length, + const int extractFlags) const; shared_ptr <header> getOrCreateHeader(); @@ -156,7 +170,7 @@ private: weak_ptr <IMAPFolder> m_folder; int m_num; - int m_size; + size_t m_size; int m_flags; bool m_expunged; uid m_uid; diff --git a/vmime/net/imap/IMAPMessagePart.hpp b/vmime/net/imap/IMAPMessagePart.hpp index f71d7d43..af8581d7 100644 --- a/vmime/net/imap/IMAPMessagePart.hpp +++ b/vmime/net/imap/IMAPMessagePart.hpp @@ -57,7 +57,7 @@ public: shared_ptr <const IMAPMessagePart> getParent() const; const mediaType& getType() const; - int getSize() const; + size_t getSize() const; int getNumber() const; shared_ptr <const header> getHeader() const; @@ -76,7 +76,7 @@ private: shared_ptr <header> m_header; int m_number; - int m_size; + size_t m_size; mediaType m_mediaType; }; diff --git a/vmime/net/imap/IMAPMessagePartContentHandler.hpp b/vmime/net/imap/IMAPMessagePartContentHandler.hpp index 80e1f0e5..cb52b2e3 100644 --- a/vmime/net/imap/IMAPMessagePartContentHandler.hpp +++ b/vmime/net/imap/IMAPMessagePartContentHandler.hpp @@ -48,12 +48,12 @@ public: shared_ptr <contentHandler> clone() const; - void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; + void generate(utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; - string::size_type getLength() const; + size_t getLength() const; bool isEncoded() const; diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp index 519cadd8..0b90829e 100644 --- a/vmime/net/imap/IMAPParser.hpp +++ b/vmime/net/imap/IMAPParser.hpp @@ -78,7 +78,7 @@ namespace imap { { public: - IMAPParserDebugResponse(const string& name, string& line, const string::size_type currentPos) + IMAPParserDebugResponse(const string& name, string& line, const size_t currentPos) : m_name(name), m_line(line), m_pos(currentPos) { ++IMAPParserDebugResponse_level; @@ -100,7 +100,7 @@ namespace imap { std::cout << string(m_line.begin() + (m_pos < 30 ? 0U : m_pos - 30), m_line.begin() + std::min(m_line.length(), m_pos + 30)) << std::endl; - for (string::size_type i = (m_pos < 30 ? m_pos : (m_pos - (m_pos - 30))) ; i != 0 ; --i) + for (size_t i = (m_pos < 30 ? m_pos : (m_pos - (m_pos - 30))) ; i != 0 ; --i) std::cout << " "; std::cout << "^" << std::endl; @@ -123,7 +123,7 @@ namespace imap { const string& m_name; string& m_line; - string::size_type m_pos; + size_t m_pos; }; @@ -287,11 +287,11 @@ public: component() { } virtual ~component() { } - virtual void go(IMAPParser& parser, string& line, string::size_type* currentPos) = 0; + virtual void go(IMAPParser& parser, string& line, size_t* currentPos) = 0; const string makeResponseLine(const string& comp, const string& line, - const string::size_type pos) + const size_t pos) { #if DEBUG_RESPONSE if (pos > line.length()) @@ -311,7 +311,7 @@ public: #define COMPONENT_ALIAS(parent, name) \ class name : public parent \ { \ - void go(IMAPParser& parser, string& line, string::size_type* currentPos) \ + void go(IMAPParser& parser, string& line, size_t* currentPos) \ { \ DEBUG_ENTER_COMPONENT(#name); \ parent::go(parser, line, currentPos); \ @@ -328,11 +328,11 @@ public: { public: - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT(string("one_char <") + C + ">: current='" + ((*currentPos < line.length() ? line[*currentPos] : '?')) + "'"); - const string::size_type pos = *currentPos; + const size_t pos = *currentPos; if (pos < line.length() && line[pos] == C) *currentPos = pos + 1; @@ -350,11 +350,11 @@ public: { public: - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("SPACE"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; while (pos < line.length() && (line[pos] == ' ' || line[pos] == '\t')) ++pos; @@ -377,11 +377,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("CRLF"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <SPACE>(line, &pos, true); @@ -414,11 +414,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("tag"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; bool end = false; @@ -489,11 +489,11 @@ public: { } - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("number"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; bool valid = true; unsigned int val = 0; @@ -567,12 +567,12 @@ public: { } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("text"); - string::size_type pos = *currentPos; - string::size_type len = 0; + size_t pos = *currentPos; + size_t len = 0; if (m_allow8bits || !parser.isStrict()) { @@ -681,11 +681,11 @@ public: { public: - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("quoted_char"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; const unsigned char c = static_cast <unsigned char>(pos < line.length() ? line[pos] : 0); @@ -730,12 +730,12 @@ public: { public: - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("quoted_text"); - string::size_type pos = *currentPos; - string::size_type len = 0; + size_t pos = *currentPos; + size_t len = 0; bool valid = false; m_value.reserve(line.length() - pos); @@ -817,11 +817,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("NIL"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.checkWithArg <special_atom>(line, &pos, "nil"); @@ -853,11 +853,11 @@ public: { } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("string"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (m_canBeNIL && parser.checkWithArg <special_atom>(line, &pos, "nil", true)) @@ -883,7 +883,7 @@ public: { m_value = "[literal-handler]"; - const string::size_type length = text->value().length(); + const size_t length = text->value().length(); utility::progressListener* progress = target->progressListener(); if (progress) @@ -920,7 +920,7 @@ public: number* num = parser.get <number>(line, &pos); - const string::size_type length = num->value(); + const size_t length = num->value(); delete (num); parser.check <one_char <'}'> >(line, &pos); @@ -1001,11 +1001,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("astring"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; xstring* str = NULL; @@ -1050,12 +1050,12 @@ public: { public: - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("atom"); - string::size_type pos = *currentPos; - string::size_type len = 0; + size_t pos = *currentPos; + size_t len = 0; for (bool end = false ; !end && pos < line.length() ; ) { @@ -1131,11 +1131,11 @@ public: { } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT(string("special_atom(") + m_string + ")"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; atom::go(parser, line, &pos); @@ -1177,11 +1177,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("text_mime2"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; atom* theCharset = NULL, *theEncoding = NULL; text* theText = NULL; @@ -1282,11 +1282,11 @@ public: delete m_number; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("seq_number"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'*'> >(line, &pos, true)) { @@ -1335,11 +1335,11 @@ public: delete m_last; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("seq_range"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_first = parser.get <seq_number>(line, &pos); @@ -1386,11 +1386,11 @@ public: delete m_nextSet; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("sequence_set"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if ((m_range = parser.get <IMAPParser::seq_range>(line, &pos, true)) == NULL) m_number = parser.get <IMAPParser::seq_number>(line, &pos); @@ -1429,11 +1429,11 @@ public: { } - void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) + void go(IMAPParser& /* parser */, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("mod_sequence_value"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; bool valid = true; vmime_uint64 val = 0; @@ -1464,7 +1464,7 @@ public: public: - const vmime_uint64 value() const { return m_value; } + vmime_uint64 value() const { return m_value; } }; @@ -1497,11 +1497,11 @@ public: delete (m_flag_keyword); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("flag_keyword"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'\\'> >(line, &pos, true)) { @@ -1587,11 +1587,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("flag_list"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); @@ -1626,11 +1626,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("mailbox"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.checkWithArg <special_atom>(line, &pos, "inbox", true)) { @@ -1677,11 +1677,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_flag"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'\\'> >(line, &pos, true)) { @@ -1755,11 +1755,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_flag_list"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); @@ -1803,11 +1803,11 @@ public: delete (m_mailbox); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_list"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_mailbox_flag_list = parser.get <IMAPParser::mailbox_flag_list>(line, &pos); @@ -1854,7 +1854,7 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("auth_type"); @@ -1914,11 +1914,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("status_att"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; // "HIGHESTMODSEQ" SP mod-sequence-valzer if (parser.checkWithArg <special_atom>(line, &pos, "highestmodseq", true)) @@ -2009,11 +2009,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("status_att_list"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_values.push_back(parser.get <IMAPParser::status_att_val>(line, &pos)); @@ -2054,11 +2054,11 @@ public: delete (m_atom); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("capability"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; class atom* at = parser.get <IMAPParser::atom>(line, &pos); @@ -2071,7 +2071,7 @@ public: (str[3] == 'h' || str[3] == 'H') && (str[4] == '=')) { - string::size_type pos = 5; + size_t pos = 5; m_auth_type = parser.get <IMAPParser::auth_type>(value, &pos); delete (at); } @@ -2116,11 +2116,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("capability_data"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.checkWithArg <special_atom>(line, &pos, "capability"); @@ -2179,11 +2179,11 @@ public: { public: - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("date_time"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; // <"> date_day_fixed "-" date_month "-" date_year parser.check <one_char <'"'> >(line, &pos); @@ -2225,9 +2225,9 @@ public: parser.check <one_char <'"'> >(line, &pos); - m_datetime.setHour(std::min(std::max(nh->value(), 0ul), 23ul)); - m_datetime.setMinute(std::min(std::max(nmi->value(), 0ul), 59ul)); - m_datetime.setSecond(std::min(std::max(ns->value(), 0ul), 59ul)); + m_datetime.setHour(static_cast <int>(std::min(std::max(nh->value(), 0ul), 23ul))); + m_datetime.setMinute(static_cast <int>(std::min(std::max(nmi->value(), 0ul), 59ul))); + m_datetime.setSecond(static_cast <int>(std::min(std::max(ns->value(), 0ul), 59ul))); const int zone = static_cast <int>(nz->value()); const int zh = zone / 100; // hour offset @@ -2235,8 +2235,8 @@ public: m_datetime.setZone(((zh * 60) + zm) * sign); - m_datetime.setDay(std::min(std::max(nd->value(), 1ul), 31ul)); - m_datetime.setYear(ny->value()); + m_datetime.setDay(static_cast <int>(std::min(std::max(nd->value(), 1ul), 31ul))); + m_datetime.setYear(static_cast <int>(ny->value())); const string month(utility::stringUtils::toLower(amo->value())); int mon = vmime::datetime::JANUARY; @@ -2328,11 +2328,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("header_list"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); @@ -2386,9 +2386,9 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'('> >(line, &pos, true)) { @@ -2445,11 +2445,11 @@ public: delete (m_header_list); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("section_text"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; // "HEADER.FIELDS" [".NOT"] SPACE header_list const bool b1 = parser.checkWithArg <special_atom>(line, &pos, "header.fields.not", true); @@ -2525,11 +2525,11 @@ public: delete (m_section_text2); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("section"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'['> >(line, &pos); @@ -2538,14 +2538,14 @@ public: if (!(m_section_text1 = parser.get <section_text>(line, &pos, true))) { nz_number* num = parser.get <nz_number>(line, &pos); - m_nz_numbers.push_back(num->value()); + m_nz_numbers.push_back(static_cast <unsigned int>(num->value())); delete (num); while (parser.check <one_char <'.'> >(line, &pos, true)) { if ((num = parser.get <nz_number>(line, &pos, true))) { - m_nz_numbers.push_back(num->value()); + m_nz_numbers.push_back(static_cast <unsigned int>(num->value())); delete (num); } else @@ -2617,11 +2617,11 @@ public: delete (m_addr_host); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("address"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); m_addr_name = parser.get <nstring>(line, &pos); @@ -2669,11 +2669,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("address_list"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (!parser.check <NIL>(line, &pos, true)) { @@ -2802,11 +2802,11 @@ public: delete (m_env_message_id); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("envelope"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); @@ -2934,11 +2934,11 @@ public: delete (m_string2); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_param_item"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_string1 = parser.get <xstring>(line, &pos); parser.check <SPACE>(line, &pos); @@ -2978,11 +2978,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_param"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'('> >(line, &pos, true)) { @@ -3031,11 +3031,11 @@ public: delete (m_body_fld_param); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_dsp"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'('> >(line, &pos, true)) { @@ -3081,11 +3081,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_lang"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'('> >(line, &pos, true)) { @@ -3140,11 +3140,11 @@ public: delete (m_body_fld_octets); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_fields"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_body_fld_param = parser.get <IMAPParser::body_fld_param>(line, &pos); parser.check <SPACE>(line, &pos); @@ -3204,11 +3204,11 @@ public: delete (m_media_subtype); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("media_text"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'"'> >(line, &pos); parser.checkWithArg <special_atom>(line, &pos, "text"); @@ -3249,11 +3249,11 @@ public: delete m_media_subtype; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("media_message"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'"'> >(line, &pos); parser.checkWithArg <special_atom>(line, &pos, "message"); @@ -3300,11 +3300,11 @@ public: delete (m_media_subtype); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("media_basic"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_media_type = parser.get <xstring>(line, &pos); @@ -3357,11 +3357,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_ext_1part"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_body_fld_md5 = parser.get <IMAPParser::body_fld_md5>(line, &pos); @@ -3444,11 +3444,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_ext_mpart"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_body_fld_param = parser.get <IMAPParser::body_fld_param>(line, &pos); @@ -3518,11 +3518,11 @@ public: delete (m_body_fields); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_type_basic"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_media_basic = parser.get <IMAPParser::media_basic>(line, &pos); parser.check <SPACE>(line, &pos); @@ -3570,11 +3570,11 @@ public: delete (m_body_fld_lines); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_type_msg"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_media_message = parser.get <IMAPParser::media_message>(line, &pos); parser.check <SPACE>(line, &pos); @@ -3631,11 +3631,11 @@ public: delete (m_body_fld_lines); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_type_text"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_media_text = parser.get <IMAPParser::media_text>(line, &pos); parser.check <SPACE>(line, &pos); @@ -3684,11 +3684,11 @@ public: delete (m_body_ext_1part); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_type_1part"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (!(m_body_type_text = parser.get <IMAPParser::body_type_text>(line, &pos, true))) if (!(m_body_type_msg = parser.get <IMAPParser::body_type_msg>(line, &pos, true))) @@ -3749,11 +3749,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body_type_mpart"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_list.push_back(parser.get <xbody>(line, &pos)); @@ -3805,11 +3805,11 @@ public: delete (m_body_type_mpart); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("body"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); @@ -3875,11 +3875,11 @@ public: delete m_mod_sequence_value; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("msg_att_item"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; // "ENVELOPE" SPACE envelope if (parser.checkWithArg <special_atom>(line, &pos, "envelope", true)) @@ -4073,11 +4073,11 @@ public: } } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("msg_att"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'('> >(line, &pos); @@ -4121,14 +4121,14 @@ public: delete (m_msg_att); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("message_data"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; nz_number* num = parser.get <nz_number>(line, &pos); - m_number = num->value(); + m_number = static_cast <unsigned int>(num->value()); delete (num); parser.check <SPACE>(line, &pos); @@ -4205,11 +4205,11 @@ public: delete m_capability_data; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("resp_text_code"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; // "ALERT" if (parser.checkWithArg <special_atom>(line, &pos, "alert", true)) @@ -4376,11 +4376,11 @@ public: delete (m_resp_text_code); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("resp_text"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.check <one_char <'['> >(line, &pos, true)) { @@ -4446,11 +4446,11 @@ public: delete (m_resp_text); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("continue_req"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'+'> >(line, &pos); parser.check <SPACE>(line, &pos); @@ -4491,11 +4491,11 @@ public: delete (m_resp_text); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("resp_cond_state"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.checkWithArg <special_atom>(line, &pos, "ok", true)) { @@ -4556,11 +4556,11 @@ public: delete (m_resp_text); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("resp_cond_bye"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.checkWithArg <special_atom>(line, &pos, "bye"); @@ -4600,11 +4600,11 @@ public: delete (m_resp_text); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("resp_cond_auth"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (parser.checkWithArg <special_atom>(line, &pos, "ok", true)) { @@ -4682,11 +4682,11 @@ public: delete m_status_att_list; } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_data"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; m_number = parser.get <IMAPParser::number>(line, &pos, true); @@ -4847,11 +4847,11 @@ public: delete (m_capability_data); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("response_data"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'*'> >(line, &pos); parser.check <SPACE>(line, &pos); @@ -4907,11 +4907,11 @@ public: delete (m_response_data); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("continue_req_or_response_data"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (!(m_continue_req = parser.get <IMAPParser::continue_req>(line, &pos, true))) m_response_data = parser.get <IMAPParser::response_data>(line, &pos); @@ -4950,11 +4950,11 @@ public: delete (m_resp_cond_bye); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("response_fatal"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'*'> >(line, &pos); parser.check <SPACE>(line, &pos); @@ -5001,11 +5001,11 @@ public: delete (m_resp_cond_state); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("response_tagged"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <IMAPParser::xtag>(line, &pos); parser.check <SPACE>(line, &pos); @@ -5052,11 +5052,11 @@ public: delete (m_response_fatal); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("response_done"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; if (!(m_response_tagged = parser.get <IMAPParser::response_tagged>(line, &pos, true))) m_response_fatal = parser.get <IMAPParser::response_fatal>(line, &pos); @@ -5101,11 +5101,11 @@ public: delete (m_response_done); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("response"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; string curLine = line; bool partial = false; // partial response @@ -5194,11 +5194,11 @@ public: delete (m_resp_cond_bye); } - void go(IMAPParser& parser, string& line, string::size_type* currentPos) + void go(IMAPParser& parser, string& line, size_t* currentPos) { DEBUG_ENTER_COMPONENT("greeting"); - string::size_type pos = *currentPos; + size_t pos = *currentPos; parser.check <one_char <'*'> >(line, &pos); parser.check <SPACE>(line, &pos); @@ -5242,7 +5242,7 @@ public: response* readResponse(literalHandler* lh = NULL) { - string::size_type pos = 0; + size_t pos = 0; string line = readLine(); m_literalHandler = lh; @@ -5257,7 +5257,7 @@ public: greeting* readGreeting() { - string::size_type pos = 0; + size_t pos = 0; string line = readLine(); greeting* greet = get <greeting>(line, &pos); @@ -5273,7 +5273,7 @@ public: // template <class TYPE> - TYPE* get(string& line, string::size_type* currentPos, + TYPE* get(string& line, size_t* currentPos, const bool noThrow = false) { component* resp = new TYPE; @@ -5282,7 +5282,7 @@ public: template <class TYPE, class ARG1_TYPE, class ARG2_TYPE> - TYPE* getWithArgs(string& line, string::size_type* currentPos, + TYPE* getWithArgs(string& line, size_t* currentPos, ARG1_TYPE arg1, ARG2_TYPE arg2, const bool noThrow = false) { component* resp = new TYPE(arg1, arg2); @@ -5293,10 +5293,10 @@ public: private: template <class TYPE> - TYPE* internalGet(component* resp, string& line, string::size_type* currentPos, + TYPE* internalGet(component* resp, string& line, size_t* currentPos, const bool noThrow = false) { - const string::size_type oldPos = *currentPos; + const size_t oldPos = *currentPos; try { @@ -5350,10 +5350,10 @@ public: // template <class TYPE> - bool check(string& line, string::size_type* currentPos, + bool check(string& line, size_t* currentPos, const bool noThrow = false) { - const string::size_type oldPos = *currentPos; + const size_t oldPos = *currentPos; try { @@ -5377,10 +5377,10 @@ public: } template <class TYPE, class ARG_TYPE> - bool checkWithArg(string& line, string::size_type* currentPos, + bool checkWithArg(string& line, size_t* currentPos, const ARG_TYPE arg, const bool noThrow = false) { - const string::size_type oldPos = *currentPos; + const size_t oldPos = *currentPos; try { @@ -5430,7 +5430,7 @@ public: const string readLine() { - string::size_type pos; + size_t pos; while ((pos = m_buffer.find('\n')) == string::npos) { @@ -5494,9 +5494,9 @@ public: } - void readLiteral(literalHandler::target& buffer, string::size_type count) + void readLiteral(literalHandler::target& buffer, size_t count) { - string::size_type len = 0; + size_t len = 0; string receiveBuffer; shared_ptr <timeoutHandler> toh = m_timeoutHandler.lock(); @@ -5550,7 +5550,7 @@ public: if (len + receiveBuffer.length() > count) { - const string::size_type remaining = count - len; + const size_t remaining = count - len; // Get the needed amount of data buffer.putData(string(receiveBuffer.begin(), receiveBuffer.begin() + remaining)); diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp index 338c6f96..5cff53fc 100644 --- a/vmime/net/maildir/maildirFolder.hpp +++ b/vmime/net/maildir/maildirFolder.hpp @@ -103,7 +103,7 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); - void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + void addMessage(utility::inputStream& is, const size_t size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessages(const folder::path& dest, const messageSet& msgs); @@ -144,7 +144,7 @@ private: void setMessageFlagsImpl(const std::vector <int>& nums, const int flags, const int mode); void copyMessagesImpl(const folder::path& dest, const std::vector <int>& nums); - void copyMessageImpl(const utility::file::path& tmpDirPath, const utility::file::path& curDirPath, const utility::file::path::component& filename, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress); + void copyMessageImpl(const utility::file::path& tmpDirPath, const utility::file::path& curDirPath, const utility::file::path::component& filename, utility::inputStream& is, const size_t size, utility::progressListener* progress); void notifyMessagesCopied(const folder::path& dest); diff --git a/vmime/net/maildir/maildirMessage.hpp b/vmime/net/maildir/maildirMessage.hpp index 6218c812..7480d49c 100644 --- a/vmime/net/maildir/maildirMessage.hpp +++ b/vmime/net/maildir/maildirMessage.hpp @@ -63,7 +63,7 @@ public: const uid getUID() const; - int getSize() const; + size_t getSize() const; bool isExpunged() const; @@ -75,8 +75,8 @@ public: int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); - void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; + void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const size_t start = 0, const size_t length = -1, const bool peek = false) const; + void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const size_t start = 0, const size_t length = -1, const bool peek = false) const; void fetchPartHeader(shared_ptr <messagePart> p); @@ -90,13 +90,13 @@ private: shared_ptr <header> getOrCreateHeader(); - void extractImpl(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool peek) const; + void extractImpl(utility::outputStream& os, utility::progressListener* progress, const size_t start, const size_t length, const size_t partialStart, const size_t partialLength, const bool peek) const; weak_ptr <maildirFolder> m_folder; int m_num; - int m_size; + size_t m_size; int m_flags; bool m_expunged; uid m_uid; diff --git a/vmime/net/maildir/maildirMessagePart.hpp b/vmime/net/maildir/maildirMessagePart.hpp index 00c931ec..3a4be0f3 100644 --- a/vmime/net/maildir/maildirMessagePart.hpp +++ b/vmime/net/maildir/maildirMessagePart.hpp @@ -56,18 +56,18 @@ public: weak_ptr <const maildirMessagePart> getParent() const { return (m_parent); } const mediaType& getType() const; - int getSize() const; + size_t getSize() const; int getNumber() const; shared_ptr <const header> getHeader() const; header& getOrCreateHeader(); - int getHeaderParsedOffset() const; - int getHeaderParsedLength() const; + size_t getHeaderParsedOffset() const; + size_t getHeaderParsedLength() const; - int getBodyParsedOffset() const; - int getBodyParsedLength() const; + size_t getBodyParsedOffset() const; + size_t getBodyParsedLength() const; void initStructure(const bodyPart& part); @@ -78,14 +78,14 @@ private: shared_ptr <header> m_header; int m_number; - int m_size; + size_t m_size; mediaType m_mediaType; - int m_headerParsedOffset; - int m_headerParsedLength; + size_t m_headerParsedOffset; + size_t m_headerParsedLength; - int m_bodyParsedOffset; - int m_bodyParsedLength; + size_t m_bodyParsedOffset; + size_t m_bodyParsedLength; }; diff --git a/vmime/net/message.hpp b/vmime/net/message.hpp index 4e291089..5bb62c53 100644 --- a/vmime/net/message.hpp +++ b/vmime/net/message.hpp @@ -90,7 +90,7 @@ public: * * @return size of the part (in bytes) */ - virtual int getSize() const = 0; + virtual size_t getSize() const = 0; /** Return the part sequence number (index). * The first part is at index zero. @@ -238,7 +238,7 @@ public: * * @return size of the message (in bytes) */ - virtual int getSize() const = 0; + virtual size_t getSize() const = 0; /** Check whether this message has been expunged (ie: definitively * deleted) and does not exist in the folder anymore. @@ -297,7 +297,12 @@ public: * be supported by the protocol (IMAP supports this), but it will NOT throw * an exception if not supported. */ - virtual void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const = 0; + virtual void extract + (utility::outputStream& os, + utility::progressListener* progress = NULL, + const size_t start = 0, + const size_t length = -1, + const bool peek = false) const = 0; /** Extract the specified MIME part of the message (header + contents). * @@ -316,8 +321,8 @@ public: (shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, - const int start = 0, - const int length = -1, + const size_t start = 0, + const size_t length = -1, const bool peek = false) const = 0; /** Fetch the MIME header for the specified part. diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp index 93a2bf35..27ea6e5f 100644 --- a/vmime/net/pop3/POP3Folder.hpp +++ b/vmime/net/pop3/POP3Folder.hpp @@ -100,7 +100,7 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); - void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + void addMessage(utility::inputStream& is, const size_t size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessages(const folder::path& dest, const messageSet& msgs); diff --git a/vmime/net/pop3/POP3Message.hpp b/vmime/net/pop3/POP3Message.hpp index 6cb3c719..87e71ba7 100644 --- a/vmime/net/pop3/POP3Message.hpp +++ b/vmime/net/pop3/POP3Message.hpp @@ -65,7 +65,7 @@ public: const uid getUID() const; - int getSize() const; + size_t getSize() const; bool isExpunged() const; @@ -77,8 +77,18 @@ public: int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); - void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; + void extract + (utility::outputStream& os, + utility::progressListener* progress = NULL, + const size_t start = 0, const size_t length = -1, + const bool peek = false) const; + + void extractPart + (shared_ptr <const messagePart> p, + utility::outputStream& os, + utility::progressListener* progress = NULL, + const size_t start = 0, const size_t length = -1, + const bool peek = false) const; void fetchPartHeader(shared_ptr <messagePart> p); @@ -93,7 +103,7 @@ private: weak_ptr <POP3Folder> m_folder; int m_num; uid m_uid; - int m_size; + size_t m_size; bool m_deleted; diff --git a/vmime/net/pop3/POP3Response.hpp b/vmime/net/pop3/POP3Response.hpp index 4b69290f..20477b5e 100644 --- a/vmime/net/pop3/POP3Response.hpp +++ b/vmime/net/pop3/POP3Response.hpp @@ -101,7 +101,7 @@ public: */ static shared_ptr <POP3Response> readLargeResponse (shared_ptr <POP3Connection> conn, utility::outputStream& os, - utility::progressListener* progress, const long predictedSize); + utility::progressListener* progress, const size_t predictedSize); /** Returns whether the response is successful ("OK"). @@ -148,7 +148,7 @@ private: void readResponseImpl(string& buffer, const bool multiLine); void readResponseImpl (string& firstLine, utility::outputStream& os, - utility::progressListener* progress, const long predictedSize); + utility::progressListener* progress, const size_t predictedSize); static bool stripFirstLine(const string& buffer, string& result, string* firstLine); diff --git a/vmime/net/sendmail/sendmailTransport.hpp b/vmime/net/sendmail/sendmailTransport.hpp index 7967ab87..d1c6aec0 100644 --- a/vmime/net/sendmail/sendmailTransport.hpp +++ b/vmime/net/sendmail/sendmailTransport.hpp @@ -68,7 +68,7 @@ public: (const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, - const utility::stream::size_type size, + const size_t size, utility::progressListener* progress = NULL, const mailbox& sender = mailbox()); @@ -80,7 +80,7 @@ private: void internalDisconnect(); void internalSend(const std::vector <string> args, utility::inputStream& is, - const utility::stream::size_type size, utility::progressListener* progress); + const size_t size, utility::progressListener* progress); string m_sendmailPath; diff --git a/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp b/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp index 6ca6c527..cfb3f50f 100644 --- a/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp +++ b/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp @@ -50,23 +50,26 @@ public: SMTPChunkingOutputStreamAdapter(shared_ptr <SMTPConnection> conn); - void write(const value_type* const data, const size_type count); void flush(); - size_type getBlockSize(); + size_t getBlockSize(); + +protected: + + void writeImpl(const byte_t* const data, const size_t count); private: SMTPChunkingOutputStreamAdapter(const SMTPChunkingOutputStreamAdapter&); - void sendChunk(const value_type* const data, const size_type count, const bool last); + void sendChunk(const byte_t* const data, const size_t count, const bool last); shared_ptr <SMTPConnection> m_connection; - value_type m_buffer[262144]; // 256 KB - size_type m_bufferSize; + byte_t m_buffer[262144]; // 256 KB + size_t m_bufferSize; unsigned int m_chunkCount; }; diff --git a/vmime/net/smtp/SMTPCommand.hpp b/vmime/net/smtp/SMTPCommand.hpp index 4005dcdf..dbb0888b 100644 --- a/vmime/net/smtp/SMTPCommand.hpp +++ b/vmime/net/smtp/SMTPCommand.hpp @@ -62,11 +62,11 @@ public: static shared_ptr <SMTPCommand> AUTH(const string& mechName); static shared_ptr <SMTPCommand> STARTTLS(); static shared_ptr <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8); - static shared_ptr <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8, const unsigned long size); + static shared_ptr <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8, const size_t size); static shared_ptr <SMTPCommand> RCPT(const mailbox& mbox, const bool utf8); static shared_ptr <SMTPCommand> RSET(); static shared_ptr <SMTPCommand> DATA(); - static shared_ptr <SMTPCommand> BDAT(const unsigned long chunkSize, const bool last); + static shared_ptr <SMTPCommand> BDAT(const size_t chunkSize, const bool last); static shared_ptr <SMTPCommand> NOOP(); static shared_ptr <SMTPCommand> QUIT(); diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp index 90ad447c..a0f02418 100644 --- a/vmime/net/smtp/SMTPTransport.hpp +++ b/vmime/net/smtp/SMTPTransport.hpp @@ -72,7 +72,7 @@ public: (const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, - const utility::stream::size_type size, + const size_t size, utility::progressListener* progress = NULL, const mailbox& sender = mailbox()); @@ -106,7 +106,7 @@ private: const mailboxList& recipients, const mailbox& sender, bool sendDATACommand, - const utility::stream::size_type size); + const size_t size); shared_ptr <SMTPConnection> m_connection; diff --git a/vmime/net/socket.hpp b/vmime/net/socket.hpp index 3dadc72b..537c34bb 100644 --- a/vmime/net/socket.hpp +++ b/vmime/net/socket.hpp @@ -55,10 +55,6 @@ public: virtual ~socket() { } - /** Type used for lengths in streams. - */ - typedef long size_type; - /** Connect to the specified address and port. * @@ -78,48 +74,54 @@ public: */ virtual bool isConnected() const = 0; - /** Receive (text) data from the socket. + /** Receive text data from the socket. * * @param buffer buffer in which to write received data */ virtual void receive(string& buffer) = 0; - /** Receive (raw) data from the socket. + /** Receive raw data from the socket. * * @param buffer buffer in which to write received data * @param count maximum number of bytes to receive (size of buffer) * @return number of bytes received/written into output buffer */ - virtual size_type receiveRaw(char* buffer, const size_type count) = 0; + virtual size_t receiveRaw(byte_t* buffer, const size_t count) = 0; - /** Send (text) data to the socket. + /** Send text data to the socket. * * @param buffer data to send */ virtual void send(const string& buffer) = 0; - /** Send (raw) data to the socket. + /** Send text data to the socket. + * + * @param str null-terminated string + */ + virtual void send(const char* str) = 0; + + /** Send raw data to the socket. * * @param buffer data to send * @param count number of bytes to send (size of buffer) */ - virtual void sendRaw(const char* buffer, const size_type count) = 0; + virtual void sendRaw(const byte_t* buffer, const size_t count) = 0; - /** Send (raw) data to the socket. + /** Send raw data to the socket. * Function may returns before all data is sent. * * @param buffer data to send * @param count number of bytes to send (size of buffer) * @return number of bytes sent */ - virtual size_type sendRawNonBlocking(const char* buffer, const size_type count) = 0; + virtual size_t sendRawNonBlocking(const byte_t* buffer, const size_t count) = 0; /** Return the preferred maximum block size when reading * from or writing to this stream. * * @return block size, in bytes */ - virtual size_type getBlockSize() const = 0; + virtual size_t getBlockSize() const = 0; /** Return the current status of this socket. * diff --git a/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp b/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp index 43848ec9..885fac13 100644 --- a/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp +++ b/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp @@ -64,13 +64,14 @@ public: bool isConnected() const; void receive(string& buffer); - size_type receiveRaw(char* buffer, const size_type count); + size_t receiveRaw(byte_t* buffer, const size_t count); void send(const string& buffer); - void sendRaw(const char* buffer, const size_type count); - size_type sendRawNonBlocking(const char* buffer, const size_type count); + void send(const char* str); + void sendRaw(const byte_t* buffer, const size_t count); + size_t sendRawNonBlocking(const byte_t* buffer, const size_t count); - size_type getBlockSize() const; + size_t getBlockSize() const; unsigned int getStatus() const; @@ -95,7 +96,7 @@ private: bool m_connected; - char m_buffer[65536]; + byte_t m_buffer[65536]; bool m_handshaking; shared_ptr <timeoutHandler> m_toHandler; diff --git a/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp b/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp index b4ff5872..3dda9fa5 100644 --- a/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp +++ b/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp @@ -68,13 +68,14 @@ public: bool isConnected() const; void receive(string& buffer); - size_type receiveRaw(char* buffer, const size_type count); + size_t receiveRaw(byte_t* buffer, const size_t count); void send(const string& buffer); - void sendRaw(const char* buffer, const size_type count); - size_type sendRawNonBlocking(const char* buffer, const size_type count); + void send(const char* str); + void sendRaw(const byte_t* buffer, const size_t count); + size_t sendRawNonBlocking(const byte_t* buffer, const size_t count); - size_type getBlockSize() const; + size_t getBlockSize() const; unsigned int getStatus() const; @@ -105,7 +106,7 @@ private: bool m_connected; - char m_buffer[65536]; + byte_t m_buffer[65536]; shared_ptr <timeoutHandler> m_toHandler; diff --git a/vmime/net/transport.hpp b/vmime/net/transport.hpp index 96e37669..6c405cbb 100644 --- a/vmime/net/transport.hpp +++ b/vmime/net/transport.hpp @@ -82,7 +82,7 @@ public: (const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, - const utility::stream::size_type size, + const size_t size, utility::progressListener* progress = NULL, const mailbox& sender = mailbox()) = 0; diff --git a/vmime/parameter.hpp b/vmime/parameter.hpp index d872b312..682c391b 100644 --- a/vmime/parameter.hpp +++ b/vmime/parameter.hpp @@ -127,15 +127,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; private: diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp index cc24ccf0..509506a9 100644 --- a/vmime/parameterizedHeaderField.hpp +++ b/vmime/parameterizedHeaderField.hpp @@ -190,15 +190,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/path.hpp b/vmime/path.hpp index 87409413..2ffa3c22 100644 --- a/vmime/path.hpp +++ b/vmime/path.hpp @@ -88,15 +88,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/platforms/posix/posixFile.hpp b/vmime/platforms/posix/posixFile.hpp index a1353841..20a56699 100644 --- a/vmime/platforms/posix/posixFile.hpp +++ b/vmime/platforms/posix/posixFile.hpp @@ -50,9 +50,12 @@ public: posixFileWriterOutputStream(const vmime::utility::file::path& path, const int fd); ~posixFileWriterOutputStream(); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: const vmime::utility::file::path m_path; @@ -72,12 +75,12 @@ public: void reset(); - size_type read(value_type* const data, const size_type count); + size_t read(byte_t* const data, const size_t count); - size_type skip(const size_type count); + size_t skip(const size_t count); - size_type getPosition() const; - void seek(const size_type pos); + size_t getPosition() const; + void seek(const size_t pos); private: diff --git a/vmime/platforms/posix/posixSocket.hpp b/vmime/platforms/posix/posixSocket.hpp index 10df657e..4ec3edec 100644 --- a/vmime/platforms/posix/posixSocket.hpp +++ b/vmime/platforms/posix/posixSocket.hpp @@ -51,13 +51,14 @@ public: void disconnect(); void receive(vmime::string& buffer); - size_type receiveRaw(char* buffer, const size_type count); + size_t receiveRaw(byte_t* buffer, const size_t count); void send(const vmime::string& buffer); - void sendRaw(const char* buffer, const size_type count); - size_type sendRawNonBlocking(const char* buffer, const size_type count); + void send(const char* str); + void sendRaw(const byte_t* buffer, const size_t count); + size_t sendRawNonBlocking(const byte_t* buffer, const size_t count); - size_type getBlockSize() const; + size_t getBlockSize() const; unsigned int getStatus() const; @@ -72,7 +73,7 @@ private: shared_ptr <vmime::net::timeoutHandler> m_timeoutHandler; - char m_buffer[65536]; + byte_t m_buffer[65536]; int m_desc; unsigned int m_status; diff --git a/vmime/platforms/windows/windowsFile.hpp b/vmime/platforms/windows/windowsFile.hpp index 65049b8f..3543ee8a 100644 --- a/vmime/platforms/windows/windowsFile.hpp +++ b/vmime/platforms/windows/windowsFile.hpp @@ -160,10 +160,10 @@ public: bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); - size_type getPosition() const; - void seek(const size_type pos); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); + size_t getPosition() const; + void seek(const size_t pos); private: @@ -198,9 +198,12 @@ public: public: - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: const vmime::utility::file::path m_path; diff --git a/vmime/platforms/windows/windowsSocket.hpp b/vmime/platforms/windows/windowsSocket.hpp index 4c4344d8..e3f43b7c 100644 --- a/vmime/platforms/windows/windowsSocket.hpp +++ b/vmime/platforms/windows/windowsSocket.hpp @@ -55,13 +55,13 @@ public: void disconnect(); void receive(vmime::string& buffer); - size_type receiveRaw(char* buffer, const size_type count); + size_t receiveRaw(char* buffer, const size_t count); void send(const vmime::string& buffer); - void sendRaw(const char* buffer, const size_type count); - size_type sendRawNonBlocking(const char* buffer, const size_type count); + void sendRaw(const char* buffer, const size_t count); + size_t sendRawNonBlocking(const char* buffer, const size_t count); - size_type getBlockSize() const; + size_t getBlockSize() const; unsigned int getStatus() const; diff --git a/vmime/relay.hpp b/vmime/relay.hpp index 62ed5bf0..35949ff1 100644 --- a/vmime/relay.hpp +++ b/vmime/relay.hpp @@ -90,15 +90,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; }; diff --git a/vmime/security/digest/md5/md5MessageDigest.hpp b/vmime/security/digest/md5/md5MessageDigest.hpp index f7dff079..ef94f5c8 100644 --- a/vmime/security/digest/md5/md5MessageDigest.hpp +++ b/vmime/security/digest/md5/md5MessageDigest.hpp @@ -42,15 +42,15 @@ public: void update(const byte_t b); void update(const string& s); - void update(const byte_t* buffer, const unsigned long len); - void update(const byte_t* buffer, const unsigned long offset, const unsigned long len); + void update(const byte_t* buffer, const size_t len); + void update(const byte_t* buffer, const size_t offset, const size_t len); void finalize(); void finalize(const string& s); - void finalize(const byte_t* buffer, const unsigned long len); - void finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len); + void finalize(const byte_t* buffer, const size_t len); + void finalize(const byte_t* buffer, const size_t offset, const size_t len); - int getDigestLength() const; + size_t getDigestLength() const; const byte_t* getDigest() const; void reset(); @@ -69,7 +69,7 @@ protected: vmime_uint8 b8[64]; }; - unsigned long m_byteCount; + size_t m_byteCount; BlockType m_block; bool m_finalized; diff --git a/vmime/security/digest/messageDigest.hpp b/vmime/security/digest/messageDigest.hpp index 512b68aa..d17dfbc2 100644 --- a/vmime/security/digest/messageDigest.hpp +++ b/vmime/security/digest/messageDigest.hpp @@ -59,7 +59,7 @@ public: * @param buffer array of bytes * @param len number of bytes to use in the buffer */ - virtual void update(const byte_t* buffer, const unsigned long len) = 0; + virtual void update(const byte_t* buffer, const size_t len) = 0; /** Updates the digest using the specified array of bytes, * starting at the specified offset. @@ -69,8 +69,8 @@ public: * @param len number of bytes to use, starting at offset */ virtual void update(const byte_t* buffer, - const unsigned long offset, - const unsigned long len) = 0; + const size_t offset, + const size_t len) = 0; /** Completes the hash computation by performing final operations * such as padding. @@ -88,22 +88,22 @@ public: * then finalize(). */ virtual void finalize(const byte_t* buffer, - const unsigned long len) = 0; + const size_t len) = 0; /** Completes the hash computation by performing final operations * such as padding. This is equivalent to calling update() and * then finalize(). */ virtual void finalize(const byte_t* buffer, - const unsigned long offset, - const unsigned long len) = 0; + const size_t offset, + const size_t len) = 0; /** Returns the length of the hash. * This is the length of the array returned by getDigest(). * * @return length of computed hash */ - virtual int getDigestLength() const = 0; + virtual size_t getDigestLength() const = 0; /** Returns the hash, as computed by the algorithm. * You must call finalize() before using this function, or the diff --git a/vmime/security/digest/sha1/sha1MessageDigest.hpp b/vmime/security/digest/sha1/sha1MessageDigest.hpp index 8d8e82a3..1eb09c2f 100644 --- a/vmime/security/digest/sha1/sha1MessageDigest.hpp +++ b/vmime/security/digest/sha1/sha1MessageDigest.hpp @@ -42,15 +42,15 @@ public: void update(const byte_t b); void update(const string& s); - void update(const byte_t* buffer, const unsigned long len); - void update(const byte_t* buffer, const unsigned long offset, const unsigned long len); + void update(const byte_t* buffer, const size_t len); + void update(const byte_t* buffer, const size_t offset, const size_t len); void finalize(); void finalize(const string& s); - void finalize(const byte_t* buffer, const unsigned long len); - void finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len); + void finalize(const byte_t* buffer, const size_t len); + void finalize(const byte_t* buffer, const size_t offset, const size_t len); - int getDigestLength() const; + size_t getDigestLength() const; const byte_t* getDigest() const; void reset(); diff --git a/vmime/security/sasl/SASLContext.hpp b/vmime/security/sasl/SASLContext.hpp index 7afcddf2..200f78db 100644 --- a/vmime/security/sasl/SASLContext.hpp +++ b/vmime/security/sasl/SASLContext.hpp @@ -93,7 +93,7 @@ public: * @param output output buffer * @param outputLen length of output buffer */ - void decodeB64(const string& input, byte_t** output, long* outputLen); + void decodeB64(const string& input, byte_t** output, size_t* outputLen); /** Helper function for encoding challenge in Base64. * @@ -101,7 +101,7 @@ public: * @param inputLen length of input buffer * @return Base64-encoded challenge */ - const string encodeB64(const byte_t* input, const long inputLen); + const string encodeB64(const byte_t* input, const size_t inputLen); private: diff --git a/vmime/security/sasl/SASLMechanism.hpp b/vmime/security/sasl/SASLMechanism.hpp index 623069d5..5492e48c 100644 --- a/vmime/security/sasl/SASLMechanism.hpp +++ b/vmime/security/sasl/SASLMechanism.hpp @@ -72,8 +72,8 @@ public: */ virtual bool step (shared_ptr <SASLSession> sess, - const byte_t* challenge, const long challengeLen, - byte_t** response, long* responseLen) = 0; + const byte_t* challenge, const size_t challengeLen, + byte_t** response, size_t* responseLen) = 0; /** Check whether authentication has completed. If false, more * calls to evaluateChallenge() are needed to complete the @@ -98,8 +98,8 @@ public: * 'outputLen' are undetermined) */ virtual void encode(shared_ptr <SASLSession> sess, - const byte_t* input, const long inputLen, - byte_t** output, long* outputLen) = 0; + const byte_t* input, const size_t inputLen, + byte_t** output, size_t* outputLen) = 0; /** Decode data according to negotiated SASL mechanism. This * might mean that data is integrity or privacy protected. @@ -115,8 +115,8 @@ public: * 'outputLen' are undetermined) */ virtual void decode(shared_ptr <SASLSession> sess, - const byte_t* input, const long inputLen, - byte_t** output, long* outputLen) = 0; + const byte_t* input, const size_t inputLen, + byte_t** output, size_t* outputLen) = 0; }; diff --git a/vmime/security/sasl/SASLSession.hpp b/vmime/security/sasl/SASLSession.hpp index 830d9970..ccf181cb 100644 --- a/vmime/security/sasl/SASLSession.hpp +++ b/vmime/security/sasl/SASLSession.hpp @@ -108,8 +108,8 @@ public: * 'responseLen' are undetermined) */ bool evaluateChallenge - (const byte_t* challenge, const long challengeLen, - byte_t** response, long* responseLen); + (const byte_t* challenge, const size_t challengeLen, + byte_t** response, size_t* responseLen); /** Return a socket in which transmitted data is integrity * and/or privacy protected, depending on the QOP (Quality of diff --git a/vmime/security/sasl/SASLSocket.hpp b/vmime/security/sasl/SASLSocket.hpp index 33487eba..e52911b4 100644 --- a/vmime/security/sasl/SASLSocket.hpp +++ b/vmime/security/sasl/SASLSocket.hpp @@ -59,13 +59,14 @@ public: bool isConnected() const; void receive(string& buffer); - size_type receiveRaw(char* buffer, const size_type count); + size_t receiveRaw(byte_t* buffer, const size_t count); void send(const string& buffer); - void sendRaw(const char* buffer, const size_type count); - size_type sendRawNonBlocking(const char* buffer, const size_type count); + void send(const char* str); + void sendRaw(const byte_t* buffer, const size_t count); + size_t sendRawNonBlocking(const byte_t* buffer, const size_t count); - size_type getBlockSize() const; + size_t getBlockSize() const; unsigned int getStatus() const; @@ -78,10 +79,10 @@ private: shared_ptr <net::socket> m_wrapped; byte_t* m_pendingBuffer; - size_type m_pendingPos; - size_type m_pendingLen; + size_t m_pendingPos; + size_t m_pendingLen; - char m_recvBuffer[65536]; + byte_t m_recvBuffer[65536]; }; diff --git a/vmime/security/sasl/builtinSASLMechanism.hpp b/vmime/security/sasl/builtinSASLMechanism.hpp index e7081a27..09b46f00 100644 --- a/vmime/security/sasl/builtinSASLMechanism.hpp +++ b/vmime/security/sasl/builtinSASLMechanism.hpp @@ -56,18 +56,18 @@ public: const string getName() const; bool step(shared_ptr <SASLSession> sess, - const byte_t* challenge, const long challengeLen, - byte_t** response, long* responseLen); + const byte_t* challenge, const size_t challengeLen, + byte_t** response, size_t* responseLen); bool isComplete() const; void encode(shared_ptr <SASLSession> sess, - const byte_t* input, const long inputLen, - byte_t** output, long* outputLen); + const byte_t* input, const size_t inputLen, + byte_t** output, size_t* outputLen); void decode(shared_ptr <SASLSession> sess, - const byte_t* input, const long inputLen, - byte_t** output, long* outputLen); + const byte_t* input, const size_t inputLen, + byte_t** output, size_t* outputLen); private: diff --git a/vmime/streamContentHandler.hpp b/vmime/streamContentHandler.hpp index 52f6718a..9b72c073 100644 --- a/vmime/streamContentHandler.hpp +++ b/vmime/streamContentHandler.hpp @@ -59,7 +59,7 @@ public: */ streamContentHandler (shared_ptr <utility::inputStream> is, - const utility::stream::size_type length, + const size_t length, const vmime::encoding& enc = NO_ENCODING); ~streamContentHandler(); @@ -80,16 +80,16 @@ public: */ void setData (shared_ptr <utility::inputStream> is, - const utility::stream::size_type length, + const size_t length, const vmime::encoding& enc = NO_ENCODING); - void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; + void generate(utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; - string::size_type getLength() const; + size_t getLength() const; bool isEncoded() const; @@ -112,7 +112,7 @@ private: // Actual data mutable shared_ptr <utility::inputStream> m_stream; - string::size_type m_length; + size_t m_length; }; diff --git a/vmime/stringContentHandler.hpp b/vmime/stringContentHandler.hpp index b8fdaa71..e9d34405 100644 --- a/vmime/stringContentHandler.hpp +++ b/vmime/stringContentHandler.hpp @@ -39,7 +39,7 @@ public: stringContentHandler(); stringContentHandler(const string& buffer, const vmime::encoding& enc = NO_ENCODING); stringContentHandler(const utility::stringProxy& str, const vmime::encoding& enc = NO_ENCODING); - stringContentHandler(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc = NO_ENCODING); + stringContentHandler(const string& buffer, const size_t start, const size_t end, const vmime::encoding& enc = NO_ENCODING); ~stringContentHandler(); @@ -60,16 +60,16 @@ public: // to generate() is different from this one... void setData(const utility::stringProxy& str, const vmime::encoding& enc = NO_ENCODING); void setData(const string& buffer, const vmime::encoding& enc = NO_ENCODING); - void setData(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc = NO_ENCODING); + void setData(const string& buffer, const size_t start, const size_t end, const vmime::encoding& enc = NO_ENCODING); stringContentHandler& operator=(const string& buffer); - void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; + void generate(utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; - string::size_type getLength() const; + size_t getLength() const; bool isEncoded() const; diff --git a/vmime/text.hpp b/vmime/text.hpp index 98e2459a..b7e25669 100644 --- a/vmime/text.hpp +++ b/vmime/text.hpp @@ -209,7 +209,7 @@ public: * @param flags encoding flags (see EncodeAndFoldFlags) */ void encodeAndFold(const generationContext& ctx, utility::outputStream& os, - const string::size_type firstLineOffset, string::size_type* lastLineLength, const int flags) const; + const size_t firstLineOffset, size_t* lastLineLength, const int flags) const; /** Decode and unfold text (RFC-2047), using the default parsing context. * @@ -255,15 +255,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; private: diff --git a/vmime/types.hpp b/vmime/types.hpp index b647d6f5..034330bc 100644 --- a/vmime/types.hpp +++ b/vmime/types.hpp @@ -29,6 +29,7 @@ #include <string> #include <vector> #include <stdexcept> +#include <cstddef> #include "vmime/config.hpp" @@ -89,9 +90,7 @@ namespace vmime typedef vmime_uint8 byte_t; typedef std::vector <byte_t> byteArray; -#if !VMIME_HAVE_SIZE_T - typedef unsigned long size_t; -#endif // !VMIME_HAVE_SIZE_T + typedef std::size_t size_t; // For compatibility with versions <= 0.7.1 (deprecated) namespace net { } diff --git a/vmime/utility/encoder/b64Encoder.hpp b/vmime/utility/encoder/b64Encoder.hpp index e2bb5780..2d23d9e3 100644 --- a/vmime/utility/encoder/b64Encoder.hpp +++ b/vmime/utility/encoder/b64Encoder.hpp @@ -42,13 +42,13 @@ public: b64Encoder(); - utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); - utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector <string> getAvailableProperties() const; - utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; - utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; + size_t getEncodedSize(const size_t n) const; + size_t getDecodedSize(const size_t n) const; protected: diff --git a/vmime/utility/encoder/encoder.hpp b/vmime/utility/encoder/encoder.hpp index 65114867..34cd10b7 100644 --- a/vmime/utility/encoder/encoder.hpp +++ b/vmime/utility/encoder/encoder.hpp @@ -54,7 +54,7 @@ public: * want to receive progress notifications * @return number of bytes written into output stream */ - virtual utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL) = 0; + virtual size_t encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL) = 0; /** Decode data. * @@ -64,7 +64,7 @@ public: * want to receive progress notifications * @return number of bytes written into output stream */ - virtual utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL) = 0; + virtual size_t decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL) = 0; /** Return the properties of the encoder. * @@ -98,7 +98,7 @@ public: * @param n count of input (decoded) bytes * @return count of output (encoded) bytes */ - virtual utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const = 0; + virtual size_t getEncodedSize(const size_t n) const = 0; /** Return the encoded size for the specified input (encoded) size. * If the size is not exact, it may be an estimate which should always @@ -107,7 +107,7 @@ public: * @param n count of input (encoded) bytes * @return count of output (decoded) bytes */ - virtual utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const = 0; + virtual size_t getDecodedSize(const size_t n) const = 0; protected: diff --git a/vmime/utility/encoder/noopEncoder.hpp b/vmime/utility/encoder/noopEncoder.hpp index 7e18e3f9..6314812b 100644 --- a/vmime/utility/encoder/noopEncoder.hpp +++ b/vmime/utility/encoder/noopEncoder.hpp @@ -42,11 +42,11 @@ public: noopEncoder(); - utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); - utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); - utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; - utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; + size_t getEncodedSize(const size_t n) const; + size_t getDecodedSize(const size_t n) const; }; diff --git a/vmime/utility/encoder/qpEncoder.hpp b/vmime/utility/encoder/qpEncoder.hpp index 254a38d0..c666795b 100644 --- a/vmime/utility/encoder/qpEncoder.hpp +++ b/vmime/utility/encoder/qpEncoder.hpp @@ -42,16 +42,16 @@ public: qpEncoder(); - utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); - utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector <string> getAvailableProperties() const; static bool RFC2047_isEncodingNeededForChar(const unsigned char c); static int RFC2047_getEncodedLength(const unsigned char c); - utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; - utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; + size_t getEncodedSize(const size_t n) const; + size_t getDecodedSize(const size_t n) const; protected: diff --git a/vmime/utility/encoder/uuEncoder.hpp b/vmime/utility/encoder/uuEncoder.hpp index f0bcbb33..7365263c 100644 --- a/vmime/utility/encoder/uuEncoder.hpp +++ b/vmime/utility/encoder/uuEncoder.hpp @@ -42,13 +42,13 @@ public: uuEncoder(); - utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); - utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + size_t decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector <string> getAvailableProperties() const; - utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; - utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; + size_t getEncodedSize(const size_t n) const; + size_t getDecodedSize(const size_t n) const; }; diff --git a/vmime/utility/filteredStream.hpp b/vmime/utility/filteredStream.hpp index 0cb7a0ef..c60373b9 100644 --- a/vmime/utility/filteredStream.hpp +++ b/vmime/utility/filteredStream.hpp @@ -42,7 +42,7 @@ class VMIME_EXPORT filteredInputStream : public inputStream { public: - virtual size_type getBlockSize(); + virtual size_t getBlockSize(); /** Return a reference to the stream being filtered. * @@ -59,7 +59,7 @@ class VMIME_EXPORT filteredOutputStream : public outputStream { public: - virtual size_type getBlockSize(); + virtual size_t getBlockSize(); /** Return a reference to the stream being filtered. * @@ -89,16 +89,16 @@ public: void reset(); - size_type read(value_type* const data, const size_type count); + size_t read(byte_t* const data, const size_t count); - size_type skip(const size_type count); + size_t skip(const size_t count); private: inputStream& m_stream; - value_type m_previousChar2; // (N - 1)th character of previous buffer - value_type m_previousChar1; // (N)th (last) character of previous buffer + byte_t m_previousChar2; // (N - 1)th character of previous buffer + byte_t m_previousChar1; // (N)th (last) character of previous buffer }; @@ -118,13 +118,16 @@ public: outputStream& getNextOutputStream(); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: outputStream& m_stream; - value_type m_previousChar; + byte_t m_previousChar; bool m_start; }; @@ -145,13 +148,16 @@ public: outputStream& getNextOutputStream(); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: outputStream& m_stream; - value_type m_previousChar; + byte_t m_previousChar; }; @@ -171,13 +177,16 @@ public: outputStream& getNextOutputStream(); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: outputStream& m_stream; - value_type m_previousChar; + byte_t m_previousChar; }; @@ -195,11 +204,22 @@ public: * @param is stream from which to read data to be filtered * @param sequence sequence on which to stop */ - stopSequenceFilteredInputStream(inputStream& is, const value_type* sequence) + stopSequenceFilteredInputStream(inputStream& is, const byte_t* sequence) : m_stream(is), m_sequence(sequence), m_found(0), m_eof(false) { } + /** Construct a new filter for the specified input stream. + * + * @param is stream from which to read data to be filtered + * @param sequence sequence on which to stop + */ + stopSequenceFilteredInputStream(inputStream& is, const char* sequence) + : m_stream(is), m_sequence(reinterpret_cast <const byte_t*>(sequence)), + m_found(0), m_eof(false) + { + } + inputStream& getPreviousInputStream() { return (m_stream); @@ -216,9 +236,9 @@ public: m_stream.reset(); } - size_type read(value_type* const data, const size_type count); + size_t read(byte_t* const data, const size_t count); - size_type skip(const size_type /* count */) + size_t skip(const size_t /* count */) { // Not supported return 0; @@ -228,21 +248,21 @@ private: inputStream& m_stream; - const value_type* m_sequence; - size_type m_found; + const byte_t* m_sequence; + size_t m_found; bool m_eof; }; template <> -stream::size_type stopSequenceFilteredInputStream <1>::read - (value_type* const data, const size_type count); +size_t stopSequenceFilteredInputStream <1>::read + (byte_t* const data, const size_t count); template <int COUNT> -stream::size_type stopSequenceFilteredInputStream <COUNT>::read - (value_type* const data, const size_type count) +size_t stopSequenceFilteredInputStream <COUNT>::read + (byte_t* const data, const size_t count) { // Read buffer must be at least 'COUNT' size + 1 byte if (eof() || count <= COUNT) @@ -252,9 +272,9 @@ stream::size_type stopSequenceFilteredInputStream <COUNT>::read { if (m_found != 0) { - const size_type found = m_found; + const size_t found = m_found; - for (size_type f = 0 ; f < found ; ++f) + for (size_t f = 0 ; f < found ; ++f) data[f] = m_sequence[f]; m_found = 0; @@ -269,10 +289,10 @@ stream::size_type stopSequenceFilteredInputStream <COUNT>::read } } - size_type read = m_stream.read(data, count - COUNT); + size_t read = m_stream.read(data, count - COUNT); - value_type* end = data + read; - value_type* pos = data; + byte_t* end = data + read; + byte_t* pos = data; while (pos < end) { @@ -344,12 +364,12 @@ stream::size_type stopSequenceFilteredInputStream <COUNT>::read // the stream data // -- shift right data - const size_type n = pos - data; + const size_t n = pos - data; - value_type* newEnd = data + read + m_found - n; - value_type* oldEnd = data + read; + byte_t* newEnd = data + read + m_found - n; + byte_t* oldEnd = data + read; - for (size_type i = 0 ; i < read - n ; ++i) + for (size_t i = 0 ; i < read - n ; ++i) { --newEnd; --oldEnd; @@ -358,7 +378,7 @@ stream::size_type stopSequenceFilteredInputStream <COUNT>::read } // -- copy the prefix just before data - for (size_type f = 0 ; f < m_found ; ++f) + for (size_t f = 0 ; f < m_found ; ++f) data[f] = m_sequence[f]; read += m_found - n; diff --git a/vmime/utility/inputStream.hpp b/vmime/utility/inputStream.hpp index 2503663c..809996ce 100644 --- a/vmime/utility/inputStream.hpp +++ b/vmime/utility/inputStream.hpp @@ -57,14 +57,14 @@ public: * @param count maximum number of bytes to read * @return number of bytes read */ - virtual size_type read(value_type* const data, const size_type count) = 0; + virtual size_t read(byte_t* const data, const size_t count) = 0; /** Skip a number of bytes. * * @param count maximum number of bytes to ignore * @return number of bytes skipped */ - virtual size_type skip(const size_type count) = 0; + virtual size_t skip(const size_t count) = 0; }; diff --git a/vmime/utility/inputStreamAdapter.hpp b/vmime/utility/inputStreamAdapter.hpp index 155debc2..dd761736 100644 --- a/vmime/utility/inputStreamAdapter.hpp +++ b/vmime/utility/inputStreamAdapter.hpp @@ -47,10 +47,10 @@ public: bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); - size_type getPosition() const; - void seek(const size_type pos); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); + size_t getPosition() const; + void seek(const size_t pos); private: diff --git a/vmime/utility/inputStreamByteBufferAdapter.hpp b/vmime/utility/inputStreamByteBufferAdapter.hpp index 4a6247f7..f201f433 100644 --- a/vmime/utility/inputStreamByteBufferAdapter.hpp +++ b/vmime/utility/inputStreamByteBufferAdapter.hpp @@ -39,21 +39,21 @@ class VMIME_EXPORT inputStreamByteBufferAdapter : public seekableInputStream { public: - inputStreamByteBufferAdapter(const byte_t* buffer, size_type length); + inputStreamByteBufferAdapter(const byte_t* buffer, size_t length); bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); - size_type getPosition() const; - void seek(const size_type pos); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); + size_t getPosition() const; + void seek(const size_t pos); private: const byte_t* m_buffer; - const size_type m_length; + const size_t m_length; - size_type m_pos; + size_t m_pos; }; diff --git a/vmime/utility/inputStreamSocketAdapter.hpp b/vmime/utility/inputStreamSocketAdapter.hpp index 8d23694d..a990f628 100644 --- a/vmime/utility/inputStreamSocketAdapter.hpp +++ b/vmime/utility/inputStreamSocketAdapter.hpp @@ -53,10 +53,10 @@ public: bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); - size_type getBlockSize(); + size_t getBlockSize(); private: diff --git a/vmime/utility/inputStreamStringAdapter.hpp b/vmime/utility/inputStreamStringAdapter.hpp index 605dd34e..4ee597e6 100644 --- a/vmime/utility/inputStreamStringAdapter.hpp +++ b/vmime/utility/inputStreamStringAdapter.hpp @@ -40,23 +40,23 @@ class VMIME_EXPORT inputStreamStringAdapter : public seekableInputStream public: inputStreamStringAdapter(const string& buffer); - inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end); + inputStreamStringAdapter(const string& buffer, const size_t begin, const size_t end); bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); - size_type getPosition() const; - void seek(const size_type pos); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); + size_t getPosition() const; + void seek(const size_t pos); private: inputStreamStringAdapter(const inputStreamStringAdapter&); const string m_buffer; // do _NOT_ keep a reference... - const string::size_type m_begin; - const string::size_type m_end; - string::size_type m_pos; + const size_t m_begin; + const size_t m_end; + size_t m_pos; }; diff --git a/vmime/utility/inputStreamStringProxyAdapter.hpp b/vmime/utility/inputStreamStringProxyAdapter.hpp index 725712a3..02dc2056 100644 --- a/vmime/utility/inputStreamStringProxyAdapter.hpp +++ b/vmime/utility/inputStreamStringProxyAdapter.hpp @@ -48,17 +48,17 @@ public: bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); - size_type getPosition() const; - void seek(const size_type pos); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); + size_t getPosition() const; + void seek(const size_t pos); private: inputStreamStringProxyAdapter(const inputStreamStringProxyAdapter&); const stringProxy& m_buffer; - string::size_type m_pos; + size_t m_pos; }; diff --git a/vmime/utility/outputStream.hpp b/vmime/utility/outputStream.hpp index 99e1e41b..62ee7336 100644 --- a/vmime/utility/outputStream.hpp +++ b/vmime/utility/outputStream.hpp @@ -49,26 +49,55 @@ public: * @param data buffer containing data to write * @param count number of bytes to write */ - virtual void write(const value_type* const data, const size_type count) = 0; + void write(const byte_t* const data, const size_t count); + + /** Write data to the stream. + * + * @param data buffer containing data to write + * @param count number of bytes to write + */ + void write(const char* const data, const size_t count); + + /** Write data to the stream. + * + * @param data buffer containing data to write + * @param N number of bytes to write, including terminating + * null (value is induced by compiler) + */ + template <int N> + void write(const char (&data)[N]) + { + write(data, N - 1); + } /** Flush this output stream and forces any buffered output * bytes to be written out to the stream. */ virtual void flush() = 0; + +protected: + + /** Write data to the stream. + * This is the method to be implemented is subclasses. + * + * @param data buffer containing data to write + * @param count number of bytes to write + */ + virtual void writeImpl(const byte_t* const data, const size_t count) = 0; }; // Helpers functions VMIME_EXPORT outputStream& operator<<(outputStream& os, const string& str); -VMIME_EXPORT outputStream& operator<<(outputStream& os, const stream::value_type c); +VMIME_EXPORT outputStream& operator<<(outputStream& os, const byte_t c); #if defined(_MSC_VER) && (_MSC_VER <= 1200) // Internal compiler error with VC++6 inline outputStream& operator<<(outputStream& os, const char* str) { - os.write(str, ::strlen(str)); + os.write(reinterpret_cast <const byte_t*>(str), ::strlen(str)); return (os); } @@ -77,7 +106,7 @@ inline outputStream& operator<<(outputStream& os, const char* str) template <int N> outputStream& operator<<(outputStream& os, const char (&str)[N]) { - os.write(str, N - 1); + os.write(reinterpret_cast <const byte_t*>(str), N - 1); return (os); } diff --git a/vmime/utility/outputStreamAdapter.hpp b/vmime/utility/outputStreamAdapter.hpp index 3228db7f..f0125584 100644 --- a/vmime/utility/outputStreamAdapter.hpp +++ b/vmime/utility/outputStreamAdapter.hpp @@ -45,9 +45,12 @@ public: */ outputStreamAdapter(std::ostream& os); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: std::ostream& m_stream; diff --git a/vmime/utility/outputStreamByteArrayAdapter.hpp b/vmime/utility/outputStreamByteArrayAdapter.hpp index ce9cf82a..a2178a9c 100644 --- a/vmime/utility/outputStreamByteArrayAdapter.hpp +++ b/vmime/utility/outputStreamByteArrayAdapter.hpp @@ -41,9 +41,12 @@ public: outputStreamByteArrayAdapter(byteArray& array); - void write(const value_type* const data, const size_type count); void flush(); +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: byteArray& m_array; diff --git a/vmime/utility/outputStreamSocketAdapter.hpp b/vmime/utility/outputStreamSocketAdapter.hpp index e80be6a3..6cd00626 100644 --- a/vmime/utility/outputStreamSocketAdapter.hpp +++ b/vmime/utility/outputStreamSocketAdapter.hpp @@ -51,10 +51,13 @@ public: outputStreamSocketAdapter(net::socket& sok); - void write(const value_type* const data, const size_type count); void flush(); - size_type getBlockSize(); + size_t getBlockSize(); + +protected: + + void writeImpl(const byte_t* const data, const size_t count); private: diff --git a/vmime/utility/outputStreamStringAdapter.hpp b/vmime/utility/outputStreamStringAdapter.hpp index 689e4307..89516827 100644 --- a/vmime/utility/outputStreamStringAdapter.hpp +++ b/vmime/utility/outputStreamStringAdapter.hpp @@ -41,10 +41,12 @@ public: outputStreamStringAdapter(string& buffer); - void write(const value_type* const data, const size_type count); void flush(); -size_type getBlockSize(){return 8192;} +protected: + + void writeImpl(const byte_t* const data, const size_t count); + private: string& m_buffer; diff --git a/vmime/utility/parserInputStreamAdapter.hpp b/vmime/utility/parserInputStreamAdapter.hpp index 16ed6f68..9b0639b1 100644 --- a/vmime/utility/parserInputStreamAdapter.hpp +++ b/vmime/utility/parserInputStreamAdapter.hpp @@ -49,19 +49,19 @@ public: bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); + size_t read(byte_t* const data, const size_t count); - void seek(const size_type pos) + void seek(const size_t pos) { m_stream->seek(pos); } - size_type skip(const size_type count) + size_t skip(const size_t count) { return m_stream->skip(count); } - size_type getPosition() const + size_t getPosition() const { return m_stream->getPosition(); } @@ -71,18 +71,18 @@ public: * * @return byte at the current position */ - value_type peekByte() const + byte_t peekByte() const { - const size_type initialPos = m_stream->getPosition(); + const size_t initialPos = m_stream->getPosition(); try { - value_type buffer[1]; - const size_type readBytes = m_stream->read(buffer, 1); + byte_t buffer[1]; + const size_t readBytes = m_stream->read(buffer, 1); m_stream->seek(initialPos); - return (readBytes == 1 ? buffer[0] : static_cast <value_type>(0)); + return (readBytes == 1 ? buffer[0] : static_cast <byte_t>(0)); } catch (...) { @@ -96,12 +96,12 @@ public: * * @return byte at the current position */ - value_type getByte() + byte_t getByte() { - value_type buffer[1]; - const size_type readBytes = m_stream->read(buffer, 1); + byte_t buffer[1]; + const size_t readBytes = m_stream->read(buffer, 1); - return (readBytes == 1 ? buffer[0] : static_cast <value_type>(0)); + return (readBytes == 1 ? buffer[0] : static_cast <byte_t>(0)); } /** Check whether the bytes following the current position match @@ -111,14 +111,15 @@ public: * @param length number of bytes * @return true if the next bytes match the pattern, false otherwise */ - bool matchBytes(const value_type* bytes, const size_type length) const + template <typename T> + bool matchBytes(const T* bytes, const size_t length) const { - const size_type initialPos = m_stream->getPosition(); + const size_t initialPos = m_stream->getPosition(); try { - value_type buffer[32]; - const size_type readBytes = m_stream->read(buffer, length); + byte_t buffer[32]; + const size_t readBytes = m_stream->read(buffer, length); m_stream->seek(initialPos); @@ -132,7 +133,7 @@ public: } } - const string extract(const size_type begin, const size_type end) const; + const string extract(const size_t begin, const size_t end) const; /** Skips bytes matching a predicate from the current position. * The current position is updated to the next following byte @@ -144,10 +145,10 @@ public: * @return number of bytes skipped */ template <typename PREDICATE> - size_type skipIf(PREDICATE pred, const size_type endPosition) + size_t skipIf(PREDICATE pred, const size_t endPosition) { - const size_type initialPos = getPosition(); - size_type pos = initialPos; + const size_t initialPos = getPosition(); + size_t pos = initialPos; while (!m_stream->eof() && pos < endPosition && pred(getByte())) ++pos; @@ -157,7 +158,7 @@ public: return pos - initialPos; } - size_type findNext(const string& token, const size_type startPosition = 0); + size_t findNext(const string& token, const size_t startPosition = 0); private: diff --git a/vmime/utility/progressListener.hpp b/vmime/utility/progressListener.hpp index 54ab9683..4d0e9bf8 100644 --- a/vmime/utility/progressListener.hpp +++ b/vmime/utility/progressListener.hpp @@ -26,6 +26,7 @@ #include "vmime/config.hpp" +#include "vmime/types.hpp" namespace vmime { @@ -58,20 +59,20 @@ public: * @param predictedTotal predicted amount of units (this has * no concrete meaning: these are not bytes, nor percentage...) */ - virtual void start(const long predictedTotal) = 0; + virtual void start(const size_t predictedTotal) = 0; /** Called during the operation (can be called several times). * * @param current current position * @param currentTotal adjusted total amount of units */ - virtual void progress(const long current, const long currentTotal) = 0; + virtual void progress(const size_t current, const size_t currentTotal) = 0; /** Called at the end of the operation. * * @param total final total amount of units */ - virtual void stop(const long total) = 0; + virtual void stop(const size_t total) = 0; }; @@ -80,7 +81,7 @@ public: * receiver, but not by the notifier. */ -class progressListenerSizeAdapter : public progressListener +class VMIME_EXPORT progressListenerSizeAdapter : public progressListener { public: @@ -89,18 +90,18 @@ public: * @param list wrapped progress listener (can be NULL) * @param total predicted total */ - progressListenerSizeAdapter(progressListener* list, const long total); + progressListenerSizeAdapter(progressListener* list, const size_t total); bool cancel() const; - void start(const long predictedTotal); - void progress(const long current, const long currentTotal); - void stop(const long total); + void start(const size_t predictedTotal); + void progress(const size_t current, const size_t currentTotal); + void stop(const size_t total); private: progressListener* m_wrapped; - long m_total; + size_t m_total; }; diff --git a/vmime/utility/random.hpp b/vmime/utility/random.hpp index 6c0aabf8..b667c3a2 100644 --- a/vmime/utility/random.hpp +++ b/vmime/utility/random.hpp @@ -65,7 +65,7 @@ public: * @param randomChars list of characters to use * @return random string */ - static const string getString(const string::size_type length, const string& randomChars + static const string getString(const size_t length, const string& randomChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); }; diff --git a/vmime/utility/seekableInputStream.hpp b/vmime/utility/seekableInputStream.hpp index f861fb0f..f56af9c4 100644 --- a/vmime/utility/seekableInputStream.hpp +++ b/vmime/utility/seekableInputStream.hpp @@ -44,7 +44,7 @@ public: * @return the offset from the beginning of the stream, in bytes, * at which the next read occurs */ - virtual size_type getPosition() const = 0; + virtual size_t getPosition() const = 0; /** Sets the position, measured from the beginning of this stream, * at which the next read occurs. @@ -52,7 +52,7 @@ public: * @param pos the offset position, measured in bytes from the * beginning of the stream, at which to set the stream pointer. */ - virtual void seek(const size_type pos) = 0; + virtual void seek(const size_t pos) = 0; }; diff --git a/vmime/utility/seekableInputStreamRegionAdapter.hpp b/vmime/utility/seekableInputStreamRegionAdapter.hpp index ce73b456..4716d2de 100644 --- a/vmime/utility/seekableInputStreamRegionAdapter.hpp +++ b/vmime/utility/seekableInputStreamRegionAdapter.hpp @@ -46,21 +46,21 @@ public: * @param length region length in source stream */ seekableInputStreamRegionAdapter(shared_ptr <seekableInputStream> stream, - const size_type begin, const size_type length); + const size_t begin, const size_t length); bool eof() const; void reset(); - size_type read(value_type* const data, const size_type count); - size_type skip(const size_type count); - size_type getPosition() const; - void seek(const size_type pos); + size_t read(byte_t* const data, const size_t count); + size_t skip(const size_t count); + size_t getPosition() const; + void seek(const size_t pos); private: shared_ptr <seekableInputStream> m_stream; - size_type m_begin; - size_type m_length; - size_type m_position; + size_t m_begin; + size_t m_length; + size_t m_position; }; diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp index 84a34f59..980a2407 100644 --- a/vmime/utility/stream.hpp +++ b/vmime/utility/stream.hpp @@ -46,24 +46,12 @@ public: virtual ~stream() { } - /** Type used to read/write one byte in the stream. - */ - typedef string::value_type value_type; - - /** Type used for lengths in streams. - */ - typedef string::size_type size_type; - - /** Constant value with the greatest possible value for an element of type size_type. - */ - static const size_type npos; - /** Return the preferred maximum block size when reading * from or writing to this stream. * * @return block size, in bytes */ - virtual size_type getBlockSize(); + virtual size_t getBlockSize(); }; diff --git a/vmime/utility/streamUtils.hpp b/vmime/utility/streamUtils.hpp index c9d63347..406b6b64 100644 --- a/vmime/utility/streamUtils.hpp +++ b/vmime/utility/streamUtils.hpp @@ -42,7 +42,7 @@ namespace utility { * @return number of bytes copied */ -VMIME_EXPORT stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os); +VMIME_EXPORT size_t bufferedStreamCopy(inputStream& is, outputStream& os); /** Copy data from one stream into another stream using a buffered method * and copying only a specified range of data. @@ -54,8 +54,8 @@ VMIME_EXPORT stream::size_type bufferedStreamCopy(inputStream& is, outputStream& * @return number of bytes copied */ -VMIME_EXPORT stream::size_type bufferedStreamCopyRange(inputStream& is, outputStream& os, - const stream::size_type start, const stream::size_type length); +VMIME_EXPORT size_t bufferedStreamCopyRange(inputStream& is, outputStream& os, + const size_t start, const size_t length); /** Copy data from one stream into another stream using a buffered method * and notify progress state of the operation. @@ -67,8 +67,8 @@ VMIME_EXPORT stream::size_type bufferedStreamCopyRange(inputStream& is, outputSt * @return number of bytes copied */ -VMIME_EXPORT stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os, - const stream::size_type length, progressListener* progress); +VMIME_EXPORT size_t bufferedStreamCopy(inputStream& is, outputStream& os, + const size_t length, progressListener* progress); } // utility diff --git a/vmime/utility/stringProxy.hpp b/vmime/utility/stringProxy.hpp index 4815c5f1..e5efa135 100644 --- a/vmime/utility/stringProxy.hpp +++ b/vmime/utility/stringProxy.hpp @@ -46,42 +46,38 @@ class VMIME_EXPORT stringProxy { public: - typedef string::size_type size_type; - typedef string string_type; - - // Consruction stringProxy(); stringProxy(const stringProxy& s); - stringProxy(const string_type& s, const size_type start = 0, const size_type end = std::numeric_limits <size_type>::max()); + stringProxy(const string& s, const size_t start = 0, const size_t end = std::numeric_limits <size_t>::max()); // Assignment - void set(const string_type& s, const size_type start = 0, const size_type end = std::numeric_limits <size_type>::max()); + void set(const string& s, const size_t start = 0, const size_t end = std::numeric_limits <size_t>::max()); void detach(); stringProxy& operator=(const stringProxy& s); - stringProxy& operator=(const string_type& s); + stringProxy& operator=(const string& s); // Extract some portion (or whole) of the string // and output it into a stream. - void extract(outputStream& os, const size_type start = 0, const size_type end = std::numeric_limits <size_type>::max(), utility::progressListener* progress = NULL) const; + void extract(outputStream& os, const size_t start = 0, const size_t end = std::numeric_limits <size_t>::max(), utility::progressListener* progress = NULL) const; // Return the "virtual" length of the string - size_type length() const; + size_t length() const; // Return the boundaries of the "virtual" string - size_type start() const; - size_type end() const; + size_t start() const; + size_t end() const; string::const_iterator it_begin() const { return (m_buffer.begin() + m_start); } string::const_iterator it_end() const { return (m_buffer.begin() + m_end); } private: - string_type m_buffer; + string m_buffer; - size_type m_start; - size_type m_end; + size_t m_start; + size_t m_end; }; diff --git a/vmime/utility/stringUtils.hpp b/vmime/utility/stringUtils.hpp index 8521092c..7d9925e2 100644 --- a/vmime/utility/stringUtils.hpp +++ b/vmime/utility/stringUtils.hpp @@ -42,6 +42,30 @@ class VMIME_EXPORT stringUtils { public: + /** Makes a string from bytes. + * + * @param data pointer to buffer containing data + * @param count number of bytes to use from buffer + * @return a string object containing a copy of the specified data + */ + static const string makeStringFromBytes(const byte_t* data, const size_t count) + { + return string(reinterpret_cast <const char*>(data), count); + } + + /** Appends bytes to a string. + * + * @param str string to which append data + * @param data pointer to buffer containing data + * @param count number of bytes to use from buffer + * @return a reference to modified string + */ + static string& appendBytesToString(string& str, const byte_t* data, const size_t count) + { + str.append(reinterpret_cast <const char*>(data), count); + return str; + } + /** Test two strings for equality (case insensitive). * \warning Use this with ASCII-only strings. * @@ -50,7 +74,7 @@ public: * @param n length of the second string * @return true if the two strings compare equally, false otherwise */ - static bool isStringEqualNoCase(const string& s1, const char* s2, const string::size_type n); + static bool isStringEqualNoCase(const string& s1, const char* s2, const size_t n); /** Test two strings for equality (case insensitive). * \warning Use this with ASCII-only strings. @@ -70,7 +94,7 @@ public: * @param n length of the second string * @return true if the two strings compare equally, false otherwise */ - static bool isStringEqualNoCase(const string::const_iterator begin, const string::const_iterator end, const char* s, const string::size_type n); + static bool isStringEqualNoCase(const string::const_iterator begin, const string::const_iterator end, const char* s, const size_t n); /** Transform all the characters in a string to lower-case. * \warning Use this with ASCII-only strings. @@ -102,7 +126,7 @@ public: * @param end end position * @return number of ASCII characters */ - static string::size_type countASCIIchars(const string::const_iterator begin, const string::const_iterator end); + static size_t countASCIIchars(const string::const_iterator begin, const string::const_iterator end); /** Returns whether the specified string is composed exclusively * of 7-bit ASCII characters. @@ -118,7 +142,7 @@ public: * @param end end position * @return position since begin, or string::npos */ - static string::size_type findFirstNonASCIIchar(const string::const_iterator begin, const string::const_iterator end); + static size_t findFirstNonASCIIchar(const string::const_iterator begin, const string::const_iterator end); /** Convert the specified value to a string value. * diff --git a/vmime/word.hpp b/vmime/word.hpp index 29d2969c..a6e2402e 100644 --- a/vmime/word.hpp +++ b/vmime/word.hpp @@ -136,15 +136,15 @@ protected: void parseImpl (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition = NULL); + const size_t position, + const size_t end, + size_t* newPosition = NULL); void generateImpl (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos = 0, - string::size_type* newLinePos = NULL) const; + const size_t curLinePos = 0, + size_t* newLinePos = NULL) const; public: @@ -154,8 +154,8 @@ public: void generate (const generationContext& ctx, utility::outputStream& os, - const string::size_type curLinePos, - string::size_type* newLinePos, + const size_t curLinePos, + size_t* newLinePos, const int flags, generatorState* state) const; #endif @@ -167,9 +167,9 @@ private: static shared_ptr <word> parseNext (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition, + const size_t position, + const size_t end, + size_t* newPosition, bool prevIsEncoded, bool* isEncoded, bool isFirst); @@ -177,9 +177,9 @@ private: static const std::vector <shared_ptr <word> > parseMultiple (const parsingContext& ctx, const string& buffer, - const string::size_type position, - const string::size_type end, - string::size_type* newPosition); + const size_t position, + const size_t end, + size_t* newPosition); // The "m_buffer" of this word holds the data, and this data is encoded diff --git a/vmime/wordEncoder.hpp b/vmime/wordEncoder.hpp index 557578fa..6f652fa2 100644 --- a/vmime/wordEncoder.hpp +++ b/vmime/wordEncoder.hpp @@ -65,7 +65,7 @@ public: * @param maxLength maximal length of the chunk * @return next chunk, of maximal length 'maxLength' if possible */ - const string getNextChunk(const string::size_type maxLength); + const string getNextChunk(const size_t maxLength); /** Return the encoding used. * @@ -93,8 +93,8 @@ public: private: string m_buffer; - string::size_type m_pos; - string::size_type m_length; + size_t m_pos; + size_t m_length; bool m_simple; |