llvm.org GIT mirror llvm / 8f7be47
Make all raw_ostreams support the tell() function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69583 91177308-0d34-0410-b5e6-96231b3b80d8 Douglas Gregor 10 years ago
2 changed file(s) with 45 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5353 delete [] OutBufStart;
5454 }
5555
56 /// tell - Return the current offset with the file.
57 uint64_t tell() { return current_pos() + GetNumBytesInBuffer(); }
58
5659 //===--------------------------------------------------------------------===//
5760 // Configuration Interface
5861 //===--------------------------------------------------------------------===//
178181 // An out of line virtual method to provide a home for the class vtable.
179182 virtual void handle();
180183
184 /// current_pos - Return the current position within the stream, not
185 /// counting the bytes currently in the buffer.
186 virtual uint64_t current_pos() = 0;
187
181188 //===--------------------------------------------------------------------===//
182189 // Private Interface
183190 //===--------------------------------------------------------------------===//
201208
202209 /// write_impl - See raw_ostream::write_impl.
203210 virtual void write_impl(const char *Ptr, unsigned Size);
211
212 /// current_pos - Return the current position within the stream, not
213 /// counting the bytes currently in the buffer.
214 virtual uint64_t current_pos() { return pos; }
215
204216 public:
205217 /// raw_fd_ostream - Open the specified file for writing. If an
206218 /// error occurs, information about the error is put into ErrorInfo,
270282
271283 /// write_impl - See raw_ostream::write_impl.
272284 virtual void write_impl(const char *Ptr, unsigned Size);
285
286 /// current_pos - Return the current position within the stream, not
287 /// counting the bytes currently in the buffer.
288 virtual uint64_t current_pos();
289
273290 public:
274291 raw_os_ostream(std::ostream &O) : OS(O) {}
275292 ~raw_os_ostream();
293
294 /// tell - Return the current offset with the stream.
295 uint64_t tell();
276296 };
277297
278298 /// raw_string_ostream - A raw_ostream that writes to an std::string. This is a
282302
283303 /// write_impl - See raw_ostream::write_impl.
284304 virtual void write_impl(const char *Ptr, unsigned Size);
305
306 /// current_pos - Return the current position within the stream, not
307 /// counting the bytes currently in the buffer.
308 virtual uint64_t current_pos() { return OS.size(); }
285309 public:
286310 raw_string_ostream(std::string &O) : OS(O) {}
287311 ~raw_string_ostream();
312
313 /// tell - Return the current offset with the stream.
314 uint64_t tell() { return OS.size() + GetNumBytesInBuffer(); }
288315
289316 /// str - Flushes the stream contents to the target string and returns
290317 /// the string's reference.
301328
302329 /// write_impl - See raw_ostream::write_impl.
303330 virtual void write_impl(const char *Ptr, unsigned Size);
331
332 /// current_pos - Return the current position within the stream, not
333 /// counting the bytes currently in the buffer.
334 virtual uint64_t current_pos();
304335 public:
305336 raw_svector_ostream(SmallVectorImpl &O) : OS(O) {}
306337 ~raw_svector_ostream();
338
339 /// tell - Return the current offset with the stream.
340 uint64_t tell();
307341 };
308342
309343 } // end llvm namespace
338338 OS.write(Ptr, Size);
339339 }
340340
341 uint64_t raw_os_ostream::current_pos() { return OS.tellp(); }
342
343 uint64_t raw_os_ostream::tell() {
344 return (uint64_t)OS.tellp() + GetNumBytesInBuffer();
345 }
346
341347 //===----------------------------------------------------------------------===//
342348 // raw_string_ostream
343349 //===----------------------------------------------------------------------===//
362368 OS.append(Ptr, Ptr + Size);
363369 }
364370
371 uint64_t raw_svector_ostream::current_pos() { return OS.size(); }
372
373 uint64_t raw_svector_ostream::tell() {
374 return OS.size() + GetNumBytesInBuffer();
375 }