adiar
adiar copied to clipboard
Move data_types/ `toString` method from test/ to src/
In test/test.h we have several stringizer functions that create pretty-printed version of the basic data types. These ought to be moved over into the respective classes in src/ such that they can be used in other ways, e.g. debugging and exceptions.
For each data type we ought to
- Create an
<<
operator overloading that gets and returns astd::ostream&
. - Add a
to_string()
method that returns thestd::string
constructed with astd::stringstream
. - Add unit tests, that make sure, they look as they are supposed to.
Data Types
- [ ]
ptr_uint64
in src/adiar/internal/data_types/ptr.h - [ ]
__uid<ptr_t>
in src/adiar/internal/data_types/uid.h - [ ]
node
in src/adiar/internal/data_types/node.h - [ ]
arc
in src/adiar/internal/data_types/arc.h - [ ]
level_info
in src/adiar/internal/data_types/level_info.h - [ ]
assignment
in src/adiar/assignment.h
Hey @SSoelvsten do you mean test/test.cpp ? . Also the paths that you have mentioned do not exist . Can you specify the entire path
The paths are based on the major refactor in #397 where lots of stuff has been moved around (and also, I mistakenly wrote the C include path rather than the project path; I fixed them now to be relative to the root of the repo, but I apologize for the confusion).
If you are interested in contributing, your contribution should build on-top of and be pull requested for the internal-cleanup branch, not main.
I would like to help here @SSoelvsten . I am a beginner so,can you tell me what to by giving a single example, so it will be clear for me as in how to proceed . Thank you
The following is a minimal example of how one creates a to_string
method and a <<
overload for a custom type (class) in C++
class A
{
private:
int a1;
int a2;
public:
A(int arg_1, int arg_2)
: a1(arg_1), a2(arg_2)
{ }
public:
std::string to_string() const
{
std::stringstream ss;
ss << "A(" << a1 << "," << a2 << ")";
return ss.str();
}
};
std::ostream& operator<< (std::ostream& os, const A &a)
{ return os << a.to_string(); }