filewritestream.h (rapidjson-1.0.2) | : | filewritestream.h (rapidjson-1.1.0) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
// http://opensource.org/licenses/MIT | // http://opensource.org/licenses/MIT | |||
// | // | |||
// Unless required by applicable law or agreed to in writing, software distribut ed | // Unless required by applicable law or agreed to in writing, software distribut ed | |||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | // CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
// specific language governing permissions and limitations under the License. | // specific language governing permissions and limitations under the License. | |||
#ifndef RAPIDJSON_FILEWRITESTREAM_H_ | #ifndef RAPIDJSON_FILEWRITESTREAM_H_ | |||
#define RAPIDJSON_FILEWRITESTREAM_H_ | #define RAPIDJSON_FILEWRITESTREAM_H_ | |||
#include "rapidjson.h" | #include "stream.h" | |||
#include <cstdio> | #include <cstdio> | |||
#ifdef __clang__ | ||||
RAPIDJSON_DIAG_PUSH | ||||
RAPIDJSON_DIAG_OFF(unreachable-code) | ||||
#endif | ||||
RAPIDJSON_NAMESPACE_BEGIN | RAPIDJSON_NAMESPACE_BEGIN | |||
//! Wrapper of C file stream for input using fread(). | //! Wrapper of C file stream for input using fread(). | |||
/*! | /*! | |||
\note implements Stream concept | \note implements Stream concept | |||
*/ | */ | |||
class FileWriteStream { | class FileWriteStream { | |||
public: | public: | |||
typedef char Ch; //!< Character type. Only support char. | typedef char Ch; //!< Character type. Only support char. | |||
skipping to change at line 60 | skipping to change at line 65 | |||
} | } | |||
if (n > 0) { | if (n > 0) { | |||
std::memset(current_, c, n); | std::memset(current_, c, n); | |||
current_ += n; | current_ += n; | |||
} | } | |||
} | } | |||
void Flush() { | void Flush() { | |||
if (current_ != buffer_) { | if (current_ != buffer_) { | |||
fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_); | size_t result = fwrite(buffer_, 1, static_cast<size_t>(current_ - bu | |||
ffer_), fp_); | ||||
if (result < static_cast<size_t>(current_ - buffer_)) { | ||||
// failure deliberately ignored at this time | ||||
// added to avoid warn_unused_result build errors | ||||
} | ||||
current_ = buffer_; | current_ = buffer_; | |||
} | } | |||
} | } | |||
// Not implemented | // Not implemented | |||
char Peek() const { RAPIDJSON_ASSERT(false); return 0; } | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } | |||
char Take() { RAPIDJSON_ASSERT(false); return 0; } | char Take() { RAPIDJSON_ASSERT(false); return 0; } | |||
size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } | |||
char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } | |||
size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } | |||
skipping to change at line 91 | skipping to change at line 100 | |||
}; | }; | |||
//! Implement specialized version of PutN() with memset() for better performance . | //! Implement specialized version of PutN() with memset() for better performance . | |||
template<> | template<> | |||
inline void PutN(FileWriteStream& stream, char c, size_t n) { | inline void PutN(FileWriteStream& stream, char c, size_t n) { | |||
stream.PutN(c, n); | stream.PutN(c, n); | |||
} | } | |||
RAPIDJSON_NAMESPACE_END | RAPIDJSON_NAMESPACE_END | |||
#ifdef __clang__ | ||||
RAPIDJSON_DIAG_POP | ||||
#endif | ||||
#endif // RAPIDJSON_FILESTREAM_H_ | #endif // RAPIDJSON_FILESTREAM_H_ | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 16 lines changed or added |