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

Class Serializer

SRC/recorder/MPCORecorder.cpp:4283–4393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4281#define SerializerFormatDouble std::setprecision(std::numeric_limits<double>::digits10 + 1)
4282
4283 class Serializer
4284 {
4285 private:
4286 std::stringstream ss;
4287
4288 public:
4289 Serializer() = default;
4290 Serializer(const char* c)
4291 : ss(c)
4292 {}
4293 inline std::string str() const {
4294 return ss.str();
4295 }
4296 explicit operator bool() const {
4297 return !ss.fail();
4298 }
4299 bool operator!() const {
4300 return ss.fail();
4301 }
4302
4303 public:
4304 inline Serializer& operator << (const std::string& x) {
4305 ss << x.length() << ' ' << x << '\n';
4306 return *this;
4307 }
4308 inline Serializer& operator << (bool x) {
4309 ss << x << '\n';
4310 return *this;
4311 }
4312 inline Serializer& operator << (int x) {
4313 ss << x << '\n';
4314 return *this;
4315 }
4316 inline Serializer& operator << (mpco::OutputFrequency::IncrementType x) {
4317 ss << static_cast<int>(x) << '\n';
4318 return *this;
4319 }
4320 inline Serializer& operator << (std::size_t x) {
4321 ss << x << '\n';
4322 return *this;
4323 }
4324 inline Serializer& operator << (double x) {
4325 ss << SerializerFormatDouble << x << '\n';
4326 return *this;
4327 }
4328 inline Serializer& operator << (const std::vector<int>& x) {
4329 ss << x.size() << '\n';
4330 for (auto i : x)
4331 ss << i << '\n';
4332 return *this;
4333 }
4334 inline Serializer& operator << (const std::vector<mpco::NodalResultType::Enum>& x) {
4335 ss << x.size() << '\n';
4336 for (auto i : x)
4337 ss << i << '\n';
4338 return *this;
4339 }
4340

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected