Page MenuHomec4science

body.cpp
No OneTemporary

File Metadata

Created
Sun, Dec 22, 15:12

body.cpp

#define _USE_VECTOR_OSTREAM // allows vector
#include "body.h"
#include <istream>
#include <ostream>
using namespace std;
istream& operator>>(istream& is, Vec2D& v)
{
char delim;
is >> std::skipws;
is >> delim;
if (delim != '(')
throw '(';
is >> v[0];
is >> delim;
if (delim != ',')
throw ',';
is >> v[1];
is >> delim;
if (delim != ')')
throw ')';
return is;
}
istream& operator>>(istream& is, Body &body)
{
is >> std::skipws;
char delim;
// begin
is >> delim;
if (delim != '{')
throw '{';
is >> body.m;
is >> delim;
if (delim != ',')
throw ',';
is >> body.x;
is >> delim;
if (delim != ',')
throw ',';
is >> body.v;
is >> delim;
if (delim != ',')
throw ',';
char fix;
is >> fix;
body.fixed = (fix == 'T');
// end
is >> delim;
if (delim != '}')
throw '}';
is >> std::noskipws;
}
ostream& operator<<(ostream& os, const Body &body)
{
os << "{" << body.m << ", " << body.x << ", " << body.v << ", " << body.fixed << "}";
return os;
}

Event Timeline