Loading...
Searching...
No Matches
memoryStreamBuffer.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::memorybuf
28
29Description
30 A std::streambuf used for memory buffer streams such as
31 ispanstream, ocharstream, etc.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Foam_memoryStreamBuffer_H
36#define Foam_memoryStreamBuffer_H
37
38#include "DynamicList.H"
39
40#include <memory>
41#include <string_view>
42#include <string>
43#include <type_traits>
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class memorybuf Declaration
52\*---------------------------------------------------------------------------*/
53
54//- A streambuf for memory similar to std::spanbuf (C++23)
55class memorybuf
56:
57 public std::streambuf
58{
59protected:
60
61 //- Set position pointer to relative position
62 virtual std::streampos seekoff
63 (
64 std::streamoff off,
65 std::ios_base::seekdir way,
66 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
67 )
68 {
69 const bool testin = which & std::ios_base::in;
70 const bool testout = which & std::ios_base::out;
71
72 if (way == std::ios_base::beg)
73 {
74 if (testin)
75 {
76 setg(eback(), eback(), egptr());
77 gbump(off);
78 }
79 if (testout)
80 {
81 setp(pbase(), epptr());
82 pbump(off);
83 }
84 }
85 else if (way == std::ios_base::cur)
86 {
87 if (testin)
88 {
89 gbump(off);
90 }
91 if (testout)
92 {
93 pbump(off);
94 }
95 }
96 else if (way == std::ios_base::end)
97 {
98 if (testin)
99 {
100 setg(eback(), eback(), egptr());
101 gbump(egptr() - eback() - off);
102 }
103 if (testout)
104 {
105 setp(pbase(), epptr());
106 pbump(epptr() - pbase() - off);
107 }
108 }
109
110 if (testin)
111 {
112 return (gptr() - eback()); // span_tellg()
113 }
114 if (testout)
115 {
116 return (pptr() - pbase()); // span_tellp()
117 }
118
119 return -1;
120 }
121
122
123 //- Set position pointer to absolute position
124 virtual std::streampos seekpos
125 (
126 std::streampos pos,
127 std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
128 )
129 {
130 return seekoff(pos, std::ios_base::beg, which);
131 }
132
133public:
134
135 // Forward Declarations
136 class in_base;
137 class in_dynamic;
138 class out_base;
139 class out_dynamic;
140};
141
142
143/*---------------------------------------------------------------------------*\
144 Class memorybuf::in_base Declaration
145\*---------------------------------------------------------------------------*/
146
147//- The base input streambuf with memory access
148class memorybuf::in_base
150 public memorybuf
151{
152protected:
153
154 //- Get sequence of characters from a fixed region
155 virtual std::streamsize xsgetn(char* s, std::streamsize n)
156 {
157 std::streamsize count = 0;
158 while (count < n && gptr() < egptr())
159 {
160 *(s + count++) = *(gptr());
161 gbump(1);
162 }
163 return count;
164 }
165
166public:
167
168 // Constructors
169
170 //- Default construct
171 in_base() = default;
172
173 //- Construct for character array (can be nullptr) and number of bytes
174 in_base(char* s, std::streamsize n)
175 {
177 }
178
179
180 // Member Functions
182 // //- Reset get buffer pointer to the beginning of existing span
183 // void rewind() { setg(eback(), eback(), egptr()); }
184
185 //- Reset get buffer with character data (can be nullptr) and count
186 // Sets get pointer to the begin.
187 void resetg(char* s, std::streamsize n)
188 {
189 if (s)
190 {
191 setg(s, s, s + n);
192 }
193 else
194 {
195 setg(nullptr, nullptr, nullptr);
196 }
198
199 //- The current buffer get position
200 std::streamsize span_tellg() const { return (gptr() - eback()); }
201
202 //- The get buffer capacity
203 std::streamsize span_capacity() const { return (egptr() - eback()); }
204
205 //- The number of characters remaining in the get area
206 std::streamsize span_remaining() const
207 {
208 return (gptr() < egptr()) ? (egptr() - gptr()) : 0;
209 }
210
211 //- The span data (start of input characters)
212 char* data_bytes() const { return eback(); }
213
214 //- The span size (number of input characters)
215 std::streamsize size_bytes() const { return (egptr() - eback()); }
216
217 //- True if position is within the current input range
218 bool in_range(std::streampos pos) const
219 {
220 return (pos >= 0 && pos < span_capacity());
221 }
223 //- A string view of the current input region
224 auto view() const
225 {
226 return std::string_view(data_bytes(), size_bytes());
227 }
228
229 //- A sub-slice string view of the current input region
230 auto view(size_t pos, size_t len) const
231 {
232 // Restrict intersection count to the current content range
233 if (len && in_range(pos))
234 {
235 if ((len == std::string::npos) || (len > (size_bytes()-pos)))
236 {
237 len = (size_bytes()-pos);
238 }
239 }
240 else
241 {
242 len = 0; // Ignore out-of-range
243 }
244
245 if (len)
246 {
247 return std::string_view(data_bytes()+pos, len);
249 else
250 {
251 return std::string_view();
252 }
253 }
254
255 //- Some information about the input buffer position/capacity
256 void info(Ostream& os) const
257 {
258 os << "get=" << span_tellg() << '/' << span_capacity();
259 }
260};
261
262
263/*---------------------------------------------------------------------------*\
264 Class memorybuf::in_dynamic Declaration
265\*---------------------------------------------------------------------------*/
266
267//- An output streambuf for memory access
269:
270 public memorybuf::in_base
271{
272private:
273
274 //- Character storage
275 List<char> storage_;
276
277
278public:
279
280 // Constructors
281
282 //- Default construct - empty
283 in_dynamic() = default;
285 //- Copy construct from content
286 in_dynamic(const char* s, std::streamsize n)
287 {
288 if (s && n)
289 {
290 storage_.resize_nocopy(n);
291 std::copy(s, (s + n), storage_.data());
292 }
293 sync_gbuffer();
294 }
295
296 //- Move construct from List
299 storage_(std::move(buffer))
300 {
301 sync_gbuffer();
302 }
303
304 //- Move construct from DynamicList (added length only)
305 template<int SizeMin>
307 {
308 storage_.transfer(buffer); // Implies shrink_to_fit
309 sync_gbuffer();
310 }
311
312
313 // Member Functions
314
315 //- Sync get buffer pointers to agree with list dimensions
316 // Sets get pointer to the begin (rewind).
318 {
319 resetg(storage_.data(), storage_.size());
320 }
321
322 //- Reset content (copy)
323 void reset(const char* s, std::streamsize n)
324 {
325 if (s && n)
326 {
327 storage_.resize_nocopy(n);
328 std::copy(s, (s + n), storage_.data());
329 }
330 else
331 {
332 storage_.clear();
333 }
334 sync_gbuffer();
336
337 //- Exchange buffer content and parameter contents, reset positions
338 void swap(List<char>& other)
339 {
340 other.swap(storage_); // Swap contents
341 sync_gbuffer();
342 }
343
344 //- Exchange buffer content and parameter contents, reset positions
345 template<int SizeMin>
347 {
348 // NB: not storage_.swap(other)! - incorrect slicing
349 other.swap(storage_); // Swap contents: implies shrink_to_fit
350 sync_gbuffer();
351 }
352
353 //- Reset buffer and return contents.
354 //- The list size and capacity are identical
356 {
357 DynamicList<char> chars(std::move(storage_));
358 sync_gbuffer();
359 return chars;
361};
362
363
364/*---------------------------------------------------------------------------*\
365 Class memorybuf::out_base Declaration
366\*---------------------------------------------------------------------------*/
367
368//- An output streambuf for memory access
370:
371 public memorybuf
372{
373protected:
374
375 //- Put sequence of characters to a fixed region
376 virtual std::streamsize xsputn(const char* s, std::streamsize n)
377 {
378 std::streamsize count = 0;
379 while (count < n && pptr() < epptr())
380 {
381 *(pptr()) = *(s + count++);
382 pbump(1);
383 }
384 return count;
386
387public:
388
389 // Constructors
390
391 //- Default construct
392 out_base() = default;
393
394 //- Construct for character array (can be nullptr) and number of bytes
395 out_base(char* s, std::streamsize n)
396 {
397 resetp(s, n);
398 }
399
400
401 // Member Functions
402
403 // //- Reset put buffer pointer to the beginning of existing span
404 // void rewind() { setp(pbase(), epptr()); }
405
406 //- Reset put buffer with character data (can be nullptr) and count
407 // Sets put pointer to the begin.
408 inline void resetp(char* s, std::streamsize n)
409 {
410 if (s)
411 {
412 // As per (std::ios_base::out && !std::ios_base::ate)
413 setp(s, s + n);
414 // No treatment for (std::ios_base::out && std::ios_base::ate)
415 }
416 else
417 {
418 setp(nullptr, nullptr);
419 }
420 }
421
422 //- The current buffer put position
423 std::streamsize span_tellp() const { return (pptr() - pbase()); }
424
425 //- The put buffer capacity
426 std::streamsize span_capacity() const { return (epptr() - pbase()); }
427
428 //- The span data (start of output characters)
429 char* data_bytes() const { return pbase(); }
430
431 //- The span size (size of output buffer)
432 std::streamsize size_bytes() const { return (pptr() - pbase()); }
433
434 //- True if position is within the current output range
435 bool in_range(std::streampos pos) const
436 {
437 return (pos >= 0 && pos < span_tellp());
438 }
439
440 //- A string view of the current output region
441 auto view() const
442 {
443 return std::string_view(data_bytes(), size_bytes());
444 }
445
446 //- A sub-slice string view of the current output region
447 auto view(size_t pos, size_t len) const
448 {
449 // Restrict intersection count to the current content range
450 if (len && in_range(pos))
451 {
452 if ((len == std::string::npos) || (len > (size_bytes()-pos)))
453 {
454 len = (size_bytes()-pos);
455 }
456 }
457 else
458 {
459 len = 0; // Ignore out-of-range
460 }
461
462 if (len)
463 {
464 return std::string_view(data_bytes()+pos, len);
465 }
466 else
467 {
468 return std::string_view();
469 }
471
472 //- Decrease the put area by 1 or more elements
473 void pop_back(int n = 1)
474 {
475 for (; (n > 0 && (pbase() < pptr())); --n)
476 {
477 pbump(-1);
478 }
479 }
480
481 //- Overwrite a sub-slice with character content
482 void overwrite
483 (
484 std::streampos pos,
485 const char* data,
486 std::streamsize count
488 {
489 if (data && (count > 0) && in_range(pos))
490 {
491 // Restrict to intersection with current content
492 if (span_tellp() <= pos+std::streampos(count))
493 {
494 count = (span_tellp() - pos);
495 }
496 std::copy(data, (data+count), (data_bytes()+pos));
498 }
499
500 //- Overwrite a single character
501 void overwrite(std::streampos pos, char c)
503 if (c && in_range(pos))
504 {
505 *(data_bytes()+pos) = c;
506 }
508
509 //- Some information about the output buffer position/capacity
510 void info(Ostream& os) const
511 {
512 os << "put=" << span_tellp() << '/' << span_capacity();
513 }
514};
516
517/*---------------------------------------------------------------------------*\
518 Class memorybuf::out_dynamic Declaration
519\*---------------------------------------------------------------------------*/
520
521//- An output streambuf for memory access
525{
526private:
527
528 //- Character storage.
529 // Internally manage like a DynamicList, with its capacity known
530 // from the list size and the addressable size known through the
531 // stream pointers.
532 List<char> storage_;
533
534protected:
535
536 //- Handle overflow
537 virtual int overflow(int_type c = traits_type::eof())
538 {
539 if (c != traits_type::eof())
540 {
541 // Needed more space?
542 extend(1);
543
544 *(pptr()) = c;
545 pbump(1);
546 }
547 return c;
548 }
549
550 //- Put sequence of characters
551 virtual std::streamsize xsputn(const char* s, std::streamsize n)
552 {
553 // Enough space so that appends work without problem
554 extend(n);
555
556 std::streamsize count = 0;
557 while (count < n && pptr() < epptr())
558 {
559 *(pptr()) = *(s + count++);
560 pbump(1);
561 }
563 return count;
564 }
565
566
567public:
568
569 // Constructors
570
571 //- Default construct - no initial reserved number of bytes.
573 {
574 sync_pbuffer();
575 }
576
577 //- Default construct with initial reserved number of bytes.
578 out_dynamic(size_t nbytes)
579 :
580 storage_(label(nbytes))
581 {
582 sync_pbuffer();
584
585 //- Move construct from List
587 :
588 storage_(std::move(buffer))
589 {
590 sync_pbuffer();
591 }
592
593 //- Move construct from DynamicList (uses entire capacity)
594 template<int SizeMin>
596 {
597 buffer.resize(buffer.capacity()); // Use entire space
598 storage_.transfer(buffer);
599 sync_pbuffer();
600 }
601
602
603 // Member Functions
604
605 //- Normal lower capacity limit.
606 // 512 bytes is a bit arbitrary but consistent with std::stringstream
607 static constexpr label min_size() noexcept { return 512; }
609 //- The largest storage size
610 static constexpr label max_size() noexcept
611 {
612 return UList<char>::max_size();
613 }
614
615 //- The 1/2 of max_size() - rounded to power-of-two
616 static constexpr label max_size_2() noexcept
617 {
618 return (1+max_size()/2);
619 }
620
621 //- The 1/4 of max_size() - rounded to power-of-two
622 static constexpr label max_size_4() noexcept
623 {
624 return (max_size_2()/2);
625 }
626
627 //- Sync put buffer pointers to agree with list dimensions.
628 // Sets put pointer to the begin (rewind).
629 void sync_pbuffer()
630 {
631 resetp(storage_.data(), storage_.size());
632 }
633
634 //- Increase capacity (if needed) and adjust buffer pointers.
635 //- Applies a min-size and capacity doubling.
636 void reserve(const std::streamsize len)
637 {
638 if (storage_.size() < len)
639 {
640 const auto cur = span_tellp(); // Output position
641
642 label size = min_size();
643
644 if (size < len)
645 {
646 // Increase capacity, but grow more slowly at the largest
647 // sizes. Expect a buffer of char to approach max_size()
648 // more commonly than buffers of other data types.
649
650 if (storage_.size() <= max_size_4())
651 {
652 // (0 < capacity <= 0.25) : fast growth (2)
653 size = label(2*storage_.size());
654 }
655 else if (storage_.size() <= max_size_2())
656 {
657 // (0.25 < capacity <= 0.5) : slower growth (1.5)
658 size = label((storage_.size()/2)*3);
659 }
660 else if (storage_.size() <= (max_size_2() + max_size_4()))
661 {
662 // (0.5 < capacity <= 0.75) : very slow growth (1.25)
663 size = label((storage_.size()/4)*5);
664 }
665 else
666 {
667 // Already very large - use max (or just len?)
668 size = max_size();
669 }
670
671 // max(size, len)
672 if (size < len)
673 {
674 size = len;
676 }
677
678 // std::cerr
679 // <<"request:" << len
680 // << " old cap:" << storage_.size()
681 // << " new cap:" << size
682 // << " pos:" << cur << endl;
683
684 storage_.resize_copy(cur, size);
686 pbump(cur);
687 }
688 }
689
690 //- Increase capacity for at least this size.
691 //- Does not apply min-size or capacity doubling etc.
692 void reserve_exact(const std::streamsize len)
693 {
694 if (storage_.size() < len)
695 {
696 const auto cur = span_tellp(); // Output position
697
698 storage_.resize_copy(cur, len);
699 sync_pbuffer();
700 pbump(cur);
701 }
702 }
703
704 //- Increase (reserve) space for another \c count entries
705 void extend(std::streamsize count)
706 {
707 reserve(span_tellp() + count);
708 }
709
710 //- Increase (reserve) space for another \c count entries
711 void extend_exact(std::streamsize count)
712 {
713 reserve_exact(span_tellp() + count);
714 }
715
716 //- Clear storage
717 void clearStorage()
718 {
719 storage_.clear();
720 sync_pbuffer();
721 }
722
723 //- Shrink storage to addressed storage
725 {
726 const auto cur = span_tellp(); // Addressed length
727
728 storage_.resize(cur);
729 sync_pbuffer();
730 pbump(cur);
731 }
733 //- Exchange buffer content and parameter contents, reset positions
734 void swap(List<char>& other)
735 {
736 const auto cur = span_tellp(); // Addressed length
737 other.swap(storage_);
738 other.resize(cur); // Truncate to output length
739 sync_pbuffer();
740 }
741
742 //- Exchange buffer content and parameter contents, reset positions
743 template<int SizeMin>
745 {
746 const auto cur = span_tellp(); // Addressed length
747
748 other.resize(other.capacity()); // Use entire space
749 other.swap(storage_); // NB: not storage_.swap(other)
750 other.resize(cur); // Restrict to output length
752 }
753
754 //- Reset buffer and return contents as a DynamicList.
755 //- The list size corresponds to the region of output.
757 {
758 const auto cur = span_tellp(); // Addressed length
759 DynamicList<char> chars(std::move(storage_));
760 chars.resize(cur); // Restrict to output length
761
762 if (chars.empty()) chars.clearStorage(); // Can destroy now
763 sync_pbuffer();
764 return chars;
765 }
766
767
768 // Housekeeping
769
770 //- Same as shrink_to_fit()
771 void shrink() { shrink_to_fit(); }
772};
773
774
775// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
776
777} // End namespace Foam
778
779// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
780
781#endif
782
783// ************************************************************************* //
label n
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void swap(List< T > &other)
Swap with plain List content. Implies shrink_to_fit().
void clearStorage()
Clear the list and delete storage.
label capacity() const noexcept
Size of the underlying storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition List.C:347
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition ListI.H:171
void resize_copy(label count, const label len)
Change allocated size of list, retaining the first count elements.
Definition List.C:31
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
bool empty() const noexcept
True if List is empty (ie, size() is zero).
Definition UList.H:701
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
Definition UListI.H:524
static constexpr label max_size() noexcept
The size of the largest possible UList.
Definition UList.H:716
T * data() noexcept
Return pointer to the underlying array serving as data storage.
Definition UListI.H:274
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
The base input streambuf with memory access.
virtual std::streamsize xsgetn(char *s, std::streamsize n)
Get sequence of characters from a fixed region.
void resetg(char *s, std::streamsize n)
Reset get buffer with character data (can be nullptr) and count.
char * data_bytes() const
The span data (start of input characters).
std::streamsize span_capacity() const
The get buffer capacity.
bool in_range(std::streampos pos) const
True if position is within the current input range.
std::streamsize span_remaining() const
The number of characters remaining in the get area.
in_base()=default
Default construct.
in_base(char *s, std::streamsize n)
Construct for character array (can be nullptr) and number of bytes.
void info(Ostream &os) const
Some information about the input buffer position/capacity.
auto view() const
A string view of the current input region.
auto view(size_t pos, size_t len) const
A sub-slice string view of the current input region.
std::streamsize span_tellg() const
The current buffer get position.
std::streamsize size_bytes() const
The span size (number of input characters).
An output streambuf for memory access.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
void swap(DynamicList< char, SizeMin > &other)
Exchange buffer content and parameter contents, reset positions.
in_dynamic(const char *s, std::streamsize n)
Copy construct from content.
in_dynamic(::Foam::DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList (added length only).
void sync_gbuffer()
Sync get buffer pointers to agree with list dimensions.
DynamicList< char > release()
Reset buffer and return contents. The list size and capacity are identical.
in_dynamic(::Foam::List< char > &&buffer)
Move construct from List.
void reset(const char *s, std::streamsize n)
Reset content (copy).
in_dynamic()=default
Default construct - empty.
An output streambuf for memory access.
out_base(char *s, std::streamsize n)
Construct for character array (can be nullptr) and number of bytes.
void overwrite(std::streampos pos, char c)
Overwrite a single character.
void resetp(char *s, std::streamsize n)
Reset put buffer with character data (can be nullptr) and count.
std::streamsize span_tellp() const
The current buffer put position.
out_base()=default
Default construct.
char * data_bytes() const
The span data (start of output characters).
std::streamsize span_capacity() const
The put buffer capacity.
bool in_range(std::streampos pos) const
True if position is within the current output range.
void info(Ostream &os) const
Some information about the output buffer position/capacity.
void overwrite(std::streampos pos, const char *data, std::streamsize count)
Overwrite a sub-slice with character content.
auto view() const
A string view of the current output region.
auto view(size_t pos, size_t len) const
A sub-slice string view of the current output region.
void pop_back(int n=1)
Decrease the put area by 1 or more elements.
std::streamsize size_bytes() const
The span size (size of output buffer).
virtual std::streamsize xsputn(const char *s, std::streamsize n)
Put sequence of characters to a fixed region.
An output streambuf for memory access.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
void shrink()
Same as shrink_to_fit().
void reserve_exact(const std::streamsize len)
Increase capacity for at least this size. Does not apply min-size or capacity doubling etc.
void swap(DynamicList< char, SizeMin > &other)
Exchange buffer content and parameter contents, reset positions.
void extend(std::streamsize count)
Increase (reserve) space for another count entries.
DynamicList< char > release()
Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output.
void shrink_to_fit()
Shrink storage to addressed storage.
void sync_pbuffer()
Sync put buffer pointers to agree with list dimensions.
virtual int overflow(int_type c=traits_type::eof())
Handle overflow.
out_dynamic(::Foam::DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList (uses entire capacity).
static constexpr label max_size_2() noexcept
The 1/2 of max_size() - rounded to power-of-two.
void clearStorage()
Clear storage.
out_dynamic(::Foam::List< char > &&buffer)
Move construct from List.
static constexpr label max_size() noexcept
The largest storage size.
static constexpr label min_size() noexcept
Normal lower capacity limit.
out_dynamic()
Default construct - no initial reserved number of bytes.
void extend_exact(std::streamsize count)
Increase (reserve) space for another count entries.
static constexpr label max_size_4() noexcept
The 1/4 of max_size() - rounded to power-of-two.
void reserve(const std::streamsize len)
Increase capacity (if needed) and adjust buffer pointers. Applies a min-size and capacity doubling.
out_dynamic(size_t nbytes)
Default construct with initial reserved number of bytes.
virtual std::streamsize xsputn(const char *s, std::streamsize n)
Put sequence of characters.
A streambuf for memory similar to std::spanbuf (C++23).
virtual std::streampos seekpos(std::streampos pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out)
Set position pointer to absolute position.
virtual std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out)
Set position pointer to relative position.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
const direction noexcept
Definition scalarImpl.H:265