MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / Serializer

Class Serializer

SRC/material/section/ASDCoupledHinge3D.cpp:331–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329 // Serialization
330#define SerializerFormatDouble std::setprecision(std::numeric_limits<double>::digits10 + 1)
331 class Serializer
332 {
333 private:
334 std::stringstream ss;
335
336 public:
337 Serializer() = default;
338 Serializer(const char* c)
339 : ss(c)
340 {}
341 inline std::string str() const {
342 return ss.str();
343 }
344 explicit operator bool() const {
345 return !ss.fail();
346 }
347 bool operator!() const {
348 return ss.fail();
349 }
350
351 public:
352 inline Serializer& operator << (std::size_t x) {
353 ss << x << '\n';
354 return *this;
355 }
356 inline Serializer& operator << (int x) {
357 ss << x << '\n';
358 return *this;
359 }
360 inline Serializer& operator << (double x) {
361 ss << SerializerFormatDouble << x << '\n';
362 return *this;
363 }
364 inline Serializer& operator << (const std::string& x) {
365 ss << x.length() << ' ' << x << '\n';
366 return *this;
367 }
368 inline Serializer& operator << (const std::vector<int>& x) {
369 ss << x.size() << '\n';
370 for (auto i : x)
371 ss << i << '\n';
372 return *this;
373 }
374 inline Serializer& operator << (const Vector& x) {
375 ss << x.Size() << '\n';
376 for (int i = 0; i < x.Size(); ++i)
377 ss << x(i) << '\n';
378 return *this;
379 }
380
381 public:
382 inline Serializer& operator >> (std::size_t& x) {
383 ss >> x;
384 return *this;
385 }
386 inline Serializer& operator >> (int& x) {
387 ss >> x;
388 return *this;

Callers

nothing calls this directly

Calls 4

lengthMethod · 0.80
sizeMethod · 0.45
SizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected