matt-42 / silicon

A high performance, middleware oriented C++14 http web framework please use matt-42/lithium instead
http://siliconframework.org
MIT License
1.72k stars 138 forks source link

"type_string" output of vector #29

Closed 84356813 closed 8 years ago

84356813 commented 8 years ago

`#include

include <silicon/api.hh>

include <silicon/api_description.hh>

include "symbols.hh"

using namespace sl; // Silicon namespace using namespace s; // Symbols namespace

int main() { typedef decltype(D(_name = std::string(), _age = int(), _city = std::string())) User;

User u("John", 23, "NYC");
std::vector<User> ul;
ul.push_back(u);
std::cout << "-----type_string(User)-----" <<std::endl;
std::cout << type_string( &u ) <<std::endl;
std::cout << "-----type_string(std::vector<user>)-----" <<std::endl;
std::cout << type_string( &ul ) <<std::endl;

return 0;

}`

out put :

-----type_string(User)-----
{name: string, age: int, city: string}
-----type_string(std::vector<user>)-----
vector of void

Is there some way to make "type_string(std::vector*)" to output "vector of {name: string, age: int, city: string}"

matt-42 commented 8 years ago

It should work now: https://github.com/matt-42/silicon/commit/9741159a5cb0133f62cd6f930781bd8707c28904#diff-60cb1e143f8c8fa9e4aca20cab1f6a50R36

84356813 commented 8 years ago

it works,but not so well. `#include

include <silicon/api.hh>

include <silicon/api_description.hh>

include "symbols.hh"

using namespace sl; // Silicon namespace using namespace s; // Symbols namespace

int main() { typedef decltype(D(_name = std::string(), _age = int(), _city = std::string())) User;

User u("John", 23, "NYC");
std::vector<User> ul;
ul.push_back(u);
auto x = D(_num=1,_date=ul);
std::cout << "-----type_string(User)-----" <<std::endl;
std::cout << type_string( &u ) <<std::endl;
std::cout << "-----type_string(std::vector<user>)-----" <<std::endl;
std::cout << type_string( &ul ) <<std::endl;
std::cout << "-----type_string(D(_num=int(1),_date=std::vector<user>()))-----" <<std::endl;
std::cout << type_string(&x) <<std::endl;
return 0;

} ` out put:

`-----type_string(User)-----

{name: string, age: int, city: string}

-----type_string(std::vector)-----

vector of {name: string, age: int, city: string}

-----type_string(D(_num=int(1),_date=std::vector()))-----

{num: int, date: vector of void}

` when a vector nesting in a sio, it does not work again;

matt-42 commented 8 years ago

Thanks for noticing. Fixed in https://github.com/matt-42/silicon/commit/e54e174e5eea17ecfd5805ff7b45e3711a8f0030