Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/Support/BinaryStreamWriter.h
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | public: | ||||
Error writeStreamRef(BinaryStreamRef Ref); | Error writeStreamRef(BinaryStreamRef Ref); | ||||
/// Efficiently reads \p Size bytes from \p Ref, and writes it to this stream. | /// Efficiently reads \p Size bytes from \p Ref, and writes it to this stream. | ||||
/// This operation will not invoke any copies of the source data, regardless | /// This operation will not invoke any copies of the source data, regardless | ||||
/// of the source stream's implementation. | /// of the source stream's implementation. | ||||
/// | /// | ||||
/// \returns a success error code if the data was successfully written, | /// \returns a success error code if the data was successfully written, | ||||
/// otherwise returns an appropriate error code. | /// otherwise returns an appropriate error code. | ||||
Error writeStreamRef(BinaryStreamRef Ref, uint32_t Size); | Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size); | ||||
/// Writes the object \p Obj to the underlying stream, as if by using memcpy. | /// Writes the object \p Obj to the underlying stream, as if by using memcpy. | ||||
/// It is up to the caller to ensure that type of \p Obj can be safely copied | /// It is up to the caller to ensure that type of \p Obj can be safely copied | ||||
/// in this fashion, as no checks are made to ensure that this is safe. | /// in this fashion, as no checks are made to ensure that this is safe. | ||||
/// | /// | ||||
/// \returns a success error code if the data was successfully written, | /// \returns a success error code if the data was successfully written, | ||||
/// otherwise returns an appropriate error code. | /// otherwise returns an appropriate error code. | ||||
template <typename T> Error writeObject(const T &Obj) { | template <typename T> Error writeObject(const T &Obj) { | ||||
Show All 37 Lines | public: | ||||
/// | /// | ||||
/// \returns a success error code if the data was successfully written, | /// \returns a success error code if the data was successfully written, | ||||
/// otherwise returns an appropriate error code. | /// otherwise returns an appropriate error code. | ||||
template <typename T> Error writeArray(FixedStreamArray<T> Array) { | template <typename T> Error writeArray(FixedStreamArray<T> Array) { | ||||
return writeStreamRef(Array.getUnderlyingStream()); | return writeStreamRef(Array.getUnderlyingStream()); | ||||
} | } | ||||
/// Splits the Writer into two Writers at a given offset. | /// Splits the Writer into two Writers at a given offset. | ||||
std::pair<BinaryStreamWriter, BinaryStreamWriter> split(uint32_t Off) const; | std::pair<BinaryStreamWriter, BinaryStreamWriter> split(uint64_t Off) const; | ||||
void setOffset(uint32_t Off) { Offset = Off; } | void setOffset(uint64_t Off) { Offset = Off; } | ||||
uint32_t getOffset() const { return Offset; } | uint64_t getOffset() const { return Offset; } | ||||
uint32_t getLength() const { return Stream.getLength(); } | uint64_t getLength() const { return Stream.getLength(); } | ||||
uint32_t bytesRemaining() const { return getLength() - getOffset(); } | uint64_t bytesRemaining() const { return getLength() - getOffset(); } | ||||
Error padToAlignment(uint32_t Align); | Error padToAlignment(uint32_t Align); | ||||
protected: | protected: | ||||
WritableBinaryStreamRef Stream; | WritableBinaryStreamRef Stream; | ||||
uint32_t Offset = 0; | uint64_t Offset = 0; | ||||
}; | }; | ||||
} // end namespace llvm | } // end namespace llvm | ||||
#endif // LLVM_SUPPORT_BINARYSTREAMWRITER_H | #endif // LLVM_SUPPORT_BINARYSTREAMWRITER_H |