Skip to content

Instantly share code, notes, and snippets.

@milan11
Created April 18, 2013 22:30
Show Gist options
  • Save milan11/5416747 to your computer and use it in GitHub Desktop.
Save milan11/5416747 to your computer and use it in GitHub Desktop.
get_set.hpp test
#include <iostream>
#include <vector>
#include <boost/integer.hpp>
#include <boost/assign/std/vector.hpp>
#include "get_set.hpp"
class Package {
public:
Package(
CONSTRUCTOR_PARAM(std::string, name),
CONSTRUCTOR_PARAM(uint32_t, version),
CONSTRUCTOR_PARAM(std::vector<std::string>, dependencies),
CONSTRUCTOR_PARAM(std::string, description)
) :
TO_FIELD(name),
TO_FIELD(version),
TO_FIELD(dependencies),
TO_FIELD(description)
{
}
FIELD_GET_SET(std::string, name)
FIELD_GET_SET(uint32_t, version)
FIELD_GET_SET(std::vector<std::string>, dependencies)
FIELD_GET_SET(std::string, description)
};
void print(const Package & pkg, std::ostream & os) {
os
<< pkg.get_name() << ','
<< pkg.get_version() << ','
<< pkg.get_description()
<< std::endl
;
}
int main() {
using namespace boost::assign;
std::vector<std::string> dependencies;
dependencies += "first", "second";
Package pkg(
"lib1",
2,
dependencies,
"A library."
);
print(pkg, std::cout);
pkg
.set_name("lib2")
.set_version(3)
.set_description("Other library.")
;
print(pkg, std::cout);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment