cppcms-users Mailing List for CppCMS C++ Web Framework (Page 64)
Brought to you by:
artyom-beilis
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
(22) |
Mar
|
Apr
(3) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
(16) |
Dec
(13) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(4) |
Feb
|
Mar
(8) |
Apr
(8) |
May
(8) |
Jun
(36) |
Jul
(63) |
Aug
(126) |
Sep
(47) |
Oct
(66) |
Nov
(46) |
Dec
(42) |
| 2011 |
Jan
(87) |
Feb
(24) |
Mar
(54) |
Apr
(21) |
May
(22) |
Jun
(18) |
Jul
(22) |
Aug
(101) |
Sep
(57) |
Oct
(33) |
Nov
(34) |
Dec
(66) |
| 2012 |
Jan
(64) |
Feb
(76) |
Mar
(73) |
Apr
(105) |
May
(93) |
Jun
(83) |
Jul
(84) |
Aug
(88) |
Sep
(57) |
Oct
(59) |
Nov
(35) |
Dec
(49) |
| 2013 |
Jan
(67) |
Feb
(17) |
Mar
(49) |
Apr
(64) |
May
(87) |
Jun
(64) |
Jul
(93) |
Aug
(23) |
Sep
(15) |
Oct
(16) |
Nov
(62) |
Dec
(73) |
| 2014 |
Jan
(5) |
Feb
(23) |
Mar
(21) |
Apr
(11) |
May
(1) |
Jun
(19) |
Jul
(27) |
Aug
(16) |
Sep
(5) |
Oct
(37) |
Nov
(12) |
Dec
(9) |
| 2015 |
Jan
(7) |
Feb
(7) |
Mar
(44) |
Apr
(28) |
May
(5) |
Jun
(12) |
Jul
(8) |
Aug
|
Sep
(39) |
Oct
(34) |
Nov
(30) |
Dec
(34) |
| 2016 |
Jan
(66) |
Feb
(23) |
Mar
(33) |
Apr
(15) |
May
(11) |
Jun
(15) |
Jul
(26) |
Aug
(4) |
Sep
(1) |
Oct
(30) |
Nov
(10) |
Dec
|
| 2017 |
Jan
(52) |
Feb
(9) |
Mar
(24) |
Apr
(16) |
May
(9) |
Jun
(12) |
Jul
(33) |
Aug
(8) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(6) |
| 2018 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(14) |
Jun
(1) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(8) |
Nov
(2) |
Dec
(2) |
| 2019 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
(6) |
Aug
(25) |
Sep
(10) |
Oct
(10) |
Nov
(6) |
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
(7) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(9) |
Oct
(1) |
Nov
|
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2026 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
|
From: bruce x. <bru...@gm...> - 2013-01-21 04:03:32
|
Hi, everyone, I set up a web service server using cppcms-1.0.2 some time
ago , outside is nginx, and it went well. A weeks ago, I removed the nginx
when I put the app to another server. And then an exception often
occured. The following is exception and trace :
-- aio::: invalid endpoint
0x7f7dc7acda18: booster::aio::endpoint::throw_invalid() const + 0xe8 in
PATH_TO_LIBS/libbooster.so.0
0x7f7dc7acdc75: booster::aio::endpoint::raw(sockaddr const*, int) + 0x25 in
PATH_TO_LIBS/libbooster.so.0
0x7f7dc7ad948b:
booster::aio::basic_socket::remote_endpoint(booster::system::error_code&) +
0xab in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7f00645:
cppcms::impl::cgi::http::process_request(booster::callback<void
(booster::system::error_code const&)> const&) + 0x3b5 in
PATH_TO_LIBS/libcppcms.so.1
0x7f7dc7f0154b:
cppcms::impl::cgi::http::some_headers_data_read(booster::system::error_code
const&, unsigned long, booster::callback<void (booster::system::error_code
const&)> const&) + 0x32b in PATH_TO_LIBS/libcppcms.so.1
0x7f7dc7ade609: ??? + 0xc7ade609 in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7ad0c6c: booster::callback<void ()>::callable_impl<void,
booster::aio::event_loop_impl::event_handler_dispatcher>::operator()() +
0x1c in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7ad2176:
booster::aio::event_loop_impl::run_one(booster::aio::reactor::event*,
unsigned long) + 0x106 in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7acf3e8: booster::aio::io_service::run() + 0x78 in
PATH_TO_LIBS/libbooster.so.0
0x7f7dc7e18c85: cppcms::service::run() + 0x65 in PATH_TO_LIBS/libcppcms.so.1
Then I traced the exception in code, and found the function in
booster/lib/aio/src/basic_socket.cpp
86 endpoint basic_socket::remote_endpoint(system::error_code &e)
87 {
88 std::vector<char> endpoint_raw_(1000,0); // apply 1000 bytes
89 sockaddr *sa = reinterpret_cast<sockaddr *>(&endpoint_raw_.front());
90 socklen_t len = endpoint_raw_.size();
91 if(::getpeername(native(),sa,&len) < 0)
92 e=geterror();
93 endpoint ep;
94 ep.raw(sa,len); // An exception thrown
95 return ep;
96 }
in booster/lib/aio/src/endpoint.cpp
228 void endpoint::raw(sockaddr const *p,int size)
229 {
230 if(size > int(sizeof(d->sa))) // sizeof(d->sa) is 256
231 throw_invalid(); //from here
232 d->size=size;
233 memcpy(&d->sa.sa,p,size);
234 }
remote_endpoint doesn't handle this exception. I don't know the reason of
the exception exactly, I doubt that someone makes trouble deliberately.
In getpeername(), when len > 256 && len <= 1000, an exception will be
thrown, normally sockaddr won't be so long.Then I want to modify the source
in remote_endpoint
>>>std::vector<char> endpoint_raw_(1000,0)
<<<std::vector<char> endpoint_raw_(256, 0)
then getpeername will handle the exception and return -1, and geterror()
will run.
It will cause any problem?
--
ZhiXin XIU
Computer Science & Engineering Dept.,
Shanghai Jiao Tong University,
800 Dongchuan Rd., Shanghai,
CHINA
|
|
From: Marcel H. <ke...@co...> - 2013-01-20 19:26:37
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 20.01.2013 20:00, schrieb Artyom Beilis: > 1. Try to upgrade CppCMS, because in 1.0.3 the automatic type > detection is already done in headers. As I said, i am on master (it's a term from git, but I think it exist in svn too. Means i have the latest svn revision checked out) > 2. It may happen if you build CppCMS in C++11 mode and use in > C++03, also I think it shouldn't be a problem in latest stable > version. But there was the problem. I built it again with c++03 standard and now it works fine. Thanks. > > Artyom Beilis -------------- Regards, -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJQ/ETlAAoJEIROXYQnkAHp1g8P/RLVCIMNq09dV6pyzyHDmbvR vUYyriZM8aYBVK3Cw44FKXOzxcK9e+zgPkOO+SJ1V7xuIINBXVYQXXr4sRfPn9ii Ond3fpBkjPx2dNvOVqEB81LBndZKH0q4EgZw8g9C/Js735jIyGvHdaoN1m+oZffF R52wHszw+o5gYyRvLf6tp8EArPIK1fkcNwarLc09CKq+0GRn1vxkKY/gnmmQx/2b vaQG7qqnXY6nLgssyhzLCWwOzqtnb5p9TGr/jNCUkAwVA1pZcOXWAUsafQqop/+2 k+A148/VWC7+hqcziIzKSgQAp2kRKCTOF3e9lgKmS8Z3Tx4y5GsAotwBterE+bUs FUGriUAHQVEiJMvGVUxBA3RkCJwAxb6elXqmTfBcWTJGHvRo9I2+HVTbSxStnUZq 3E2PEuKEaMqwkiIklMQxk9/wWvc7YBmCxGLwvKpvuvX1v4JU9zn3UPMzC95J3kJq W0GDr23DIIgNhTFg7U0lvGveelU2oXG0H3RDNMMcay4m1poYSWeaJ1998kCFjxG9 RO4gFhji6UgAqPrUkQTSagAm4VJoFMHhHDog5GC2bUC6EznUSTYWRJs82YkXfzYy 5Ef5ov07rx1y2ksKBTvYM5PfiVCPRQt/gMoCIKESGFuPv//mlfuUgE2uIaCex4nn +ARcrfpMkNZYzsJ32r2i =Uwjq -----END PGP SIGNATURE----- |
|
From: Artyom B. <art...@ya...> - 2013-01-20 19:00:31
|
1. Try to upgrade CppCMS, because in 1.0.3 the automatic type detection is already done in headers. 2. It may happen if you build CppCMS in C++11 mode and use in C++03, also I think it shouldn't be a problem in latest stable version. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ ----- Original Message ----- > From: Marcel Hellwig <ke...@co...> > To: cpp...@li... > Cc: > Sent: Sunday, January 20, 2013 7:58 PM > Subject: Re: [Cppcms-users] message board fails to build > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Am 20.01.2013 12:00, schrieb Marcel Hellwig: >> Hello everyone, >> >> If I try to build the message board example, it will fail with >> some nasty errors (see attached log). I am on cppcms/cppdb master. >> >> Can anyone confirm/fix this? >> > I found a solution by myself. If you try to compile it with std=c++11 > it will work fine. > Regarding to this page[0] the foreach loop is the bad guy. Maybe you > have other suggestions? > > [0] > http://cppcms.com/wikipp/en/page/cppcms_1x_templates_flow#Type.detection >> Regards Marcel Hellwig > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.13 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQIcBAEBAgAGBQJQ/DBVAAoJEIROXYQnkAHpyuUP/iuTACHUJVBtOmMQeXW/sajd > 59n4lJfF4Zcw5MgaQfzm22o8Z6Y7t8E7EBUZrvp57jbkLgtFHOdY371cMLl2Ztpo > 5ExE7Smg+33aFcZUuC3PSLCTmP3nCix9ub4q2gsZhuaMWBptRhT+cn2aYWHcSig3 > H97DeXmIiL3hPuv50WnWIKsm+TBrGqKEwwCYaJq0UVUdkHYShc1TDqZ3l1wQTc1k > cbAmXgJC/l44abQvql/61r2DPAUj9k1zv6KDNLY3iaf/FYiddZzxdp3fVU9sUyhO > sOCbZauGTHhOONE7ugYHdiiVzgTMaXNlqJ1xJVMutuWI0w3g0Pe/AmtWwd07+s7K > kL+pQLRKoe+q3JqBJ7tJ6jePOryzN5mCxCqBp26twIcqTc8+XzeLH+1cLxUpbjYn > 8dGYZUwz6T6ctscNrALPDquOG2v7QvLmP8LX0eShXyRNROFMFAIz1Okl9FeCbECM > X3tPhlHp2TkmMC9stQ24DSdVeu9TBY7WYI6OPDTcuMpw5f3Qyq06rrMa6AYXxa+F > umZ95Eed+b1BiZhZS8rRqhpxDaiHOLyQ6aBkdKImWEtizav+Qxxoe4t22Y086k3d > Bi9v4H/TJOoAMdB6s6rAgGHw+a9Yq8YpLIeWDkPnqODKKGVxouV+KxB9vsxKQhLb > biohF2hew0s+NqvELbJW > =48LY > -----END PGP SIGNATURE----- > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnmore_123012 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
|
From: Marcel H. <ke...@co...> - 2013-01-20 17:58:54
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 20.01.2013 12:00, schrieb Marcel Hellwig: > Hello everyone, > > If I try to build the message board example, it will fail with > some nasty errors (see attached log). I am on cppcms/cppdb master. > > Can anyone confirm/fix this? > I found a solution by myself. If you try to compile it with std=c++11 it will work fine. Regarding to this page[0] the foreach loop is the bad guy. Maybe you have other suggestions? [0] http://cppcms.com/wikipp/en/page/cppcms_1x_templates_flow#Type.detection > Regards Marcel Hellwig -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJQ/DBVAAoJEIROXYQnkAHpyuUP/iuTACHUJVBtOmMQeXW/sajd 59n4lJfF4Zcw5MgaQfzm22o8Z6Y7t8E7EBUZrvp57jbkLgtFHOdY371cMLl2Ztpo 5ExE7Smg+33aFcZUuC3PSLCTmP3nCix9ub4q2gsZhuaMWBptRhT+cn2aYWHcSig3 H97DeXmIiL3hPuv50WnWIKsm+TBrGqKEwwCYaJq0UVUdkHYShc1TDqZ3l1wQTc1k cbAmXgJC/l44abQvql/61r2DPAUj9k1zv6KDNLY3iaf/FYiddZzxdp3fVU9sUyhO sOCbZauGTHhOONE7ugYHdiiVzgTMaXNlqJ1xJVMutuWI0w3g0Pe/AmtWwd07+s7K kL+pQLRKoe+q3JqBJ7tJ6jePOryzN5mCxCqBp26twIcqTc8+XzeLH+1cLxUpbjYn 8dGYZUwz6T6ctscNrALPDquOG2v7QvLmP8LX0eShXyRNROFMFAIz1Okl9FeCbECM X3tPhlHp2TkmMC9stQ24DSdVeu9TBY7WYI6OPDTcuMpw5f3Qyq06rrMa6AYXxa+F umZ95Eed+b1BiZhZS8rRqhpxDaiHOLyQ6aBkdKImWEtizav+Qxxoe4t22Y086k3d Bi9v4H/TJOoAMdB6s6rAgGHw+a9Yq8YpLIeWDkPnqODKKGVxouV+KxB9vsxKQhLb biohF2hew0s+NqvELbJW =48LY -----END PGP SIGNATURE----- |
|
From: Marcel H. <ke...@co...> - 2013-01-20 11:19:15
|
Hello everyone, If I try to build the message board example, it will fail with some nasty errors (see attached log). I am on cppcms/cppdb master. Can anyone confirm/fix this? Regards Marcel Hellwig |
|
From: Sab <rim...@gm...> - 2013-01-18 12:35:47
|
Hi guys, I would like to implement something like a proxy. In a normal case I process http requests in my CppCMS application from clients and return some response but in some special cases I need to function as a client: to send the request further to another webserver, get some resource back as response and return that as my response to my client. Any suggestions how I could realize this with the least effort? I found some libraries that could do the trick but I was wondering if I could do the same thing by only using CppCMS. If the answer is no, I would appreciate some suggestions from those of you, who already used a library that can do it (e.g. libcurl, poco, etc). Sab |
|
From: Sergey S. <ser...@gm...> - 2013-01-14 09:57:07
|
Poblem is: Catched exception: cppdb::mysql::Lost connection to MySQL server during query |
|
From: Sergey S. <ser...@gm...> - 2013-01-13 21:35:10
|
In localhost all fine. I dont know. I think, server restart is good solution :) |
|
From: Sergey S. <ser...@gm...> - 2013-01-13 21:10:47
|
Funny. All this time it working very well. Today broke. |
|
From: Sergey S. <ser...@gm...> - 2013-01-13 21:03:41
|
I think problem in sql connection. First message going fine and something
hapens. But log is empty. I dont know what is a problem. Pointer?
void post(std::string const &message)
{
cppdb::statement stmt;
stmt = sql()
<< "INSERT INTO chat(uid,author,css,image,message,date)
VALUES(?,?,?,?,?,?)"
<< uid
<< author_.name
<< author_.css
<< author_.image
<< cppcms::util::escape(message)
<< mktime(&date)
<< cppdb::exec;
int last_id = stmt.last_insert_id();
cppcms::json::value obj;
obj["id"] = last_id;
obj["uid"] = uid;
obj["author"] = author_.name;
obj["css"] = author_.css;
obj["image"] = author_.image;
obj["message"] = cppcms::util::escape(message);
obj["date"] = mktime(&date);
messages_.push_back(obj);
}
cppdb::session &sql()
{
if(!sql_->is_open())
sql_->open(connection_string_);
return *sql_;
}
private:
std::auto_ptr<cppdb::session> sql_;
|
|
From: Artyom B. <art...@ya...> - 2013-01-13 20:51:48
|
Any logs? What does it mean does not work? Errors in log? Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Sergey Shutov <ser...@gm...> >To: cpp...@li... >Sent: Sunday, January 13, 2013 9:12 PM >Subject: Re: [Cppcms-users] Writing response failed:aio::: > >Nop. Works only if >"daemon" : { "enable" : false } > > >------------------------------------------------------------------------------ >Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >MVPs and experts. ON SALE this month only -- learn more at: >http://p.sf.net/sfu/learnmore_123012 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
|
From: Artyom B. <art...@ya...> - 2013-01-13 20:50:24
|
that meens that the connection was closed Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Sergey Shutov <ser...@gm...> >To: cpp...@li... >Sent: Sunday, January 13, 2013 7:29 PM >Subject: [Cppcms-users] Writing response failed:aio::: > >What is mean? > >2013-01-13 18:33:29; cppcms, warning: Writing response failed:aio::: connection >hang-up or invalid discriptor tested (cgi_api.cpp:457) > > > >------------------------------------------------------------------------------ >Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >MVPs and experts. ON SALE this month only -- learn more at: >http://p.sf.net/sfu/learnmore_123012 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
|
From: Sergey S. <ser...@gm...> - 2013-01-13 19:12:52
|
Nop. Works only if
"daemon" : { "enable" : false }
|
|
From: Sergey S. <ser...@gm...> - 2013-01-13 18:52:36
|
Artyom something wrong with daemon. With daemon true in filebase.ws chat /get works and /post not. With false is works. Tmp i run the chat like that sudo ./chat -c config.js& |
|
From: Sergey S. <ser...@gm...> - 2013-01-13 17:29:58
|
What is mean? 2013-01-13 18:33:29; cppcms, warning: Writing response failed:aio::: connection hang-up or invalid discriptor tested (cgi_api.cpp:457) |
|
From: Artyom B. <art...@ya...> - 2013-01-11 15:40:20
|
sizeof(msg) == sizeof(char const *) != length of string...
sizeof(msg) == Size of pointer
> void send_msg(const char *msg) {
> ...
> w_bytes = socket_.write(booster::aio::buffer(msg,
sizeof(msg)), err);
>--
>Fatol Sergiu Adrian
>Team Leader & Senior PHP Developer
>Arobs Transilvania Software
>
>adi...@ar...
>
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
|
|
From: Sergey S. <ser...@gm...> - 2013-01-11 14:55:01
|
http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/echo/blocking_tc p_echo_client.cpp |
|
From: Sergey S. <ser...@gm...> - 2013-01-11 14:51:20
|
http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html |
|
From: Sab <rim...@gm...> - 2013-01-11 14:16:24
|
Hi guys, Is there any function in CppCMS framework that parses the query_string of a request into field-value pairs? Not that it would be a big deal to write an own parser, I just wanna make sure I don't rediscover the wheel... Sab |
|
From: adi.fatol <adi...@ar...> - 2013-01-11 13:51:35
|
Hello all, I am a PHP developer and I want make a few tests using the cppcms framework. I know C/C++ but I have little experience using it. I use an "echo server" written in PHP, you can find it here: http://php.net/manual/en/sockets.examples.php. I want to send a message to the server. For this I use this function I have implemented: void send_msg(const char *msg) { booster::aio::stream_socket socket_; booster::system::error_code err; int w_bytes, r_bytes; booster::aio::endpoint ep("127.0.0.1", 10000); std::cout << "connecting..." << std::endl; socket_.open(booster::aio::family_type::pf_inet, err); std::cout << "open error: " << err.value() << std::endl; socket_.connect(ep, err); std::cout << "connection error: " << err.value() << std::endl; try { w_bytes = socket_.write(booster::aio::buffer(msg, sizeof(msg)), err); std::cout << "written bytes: " << w_bytes << std::endl; } catch (booster::system::system_error write_err) { std::cout << "Exception raised: " << write_err.code() << '\n'; } socket_.shutdown(booster::aio::stream_socket::how_type::shut_rdwr); socket_.close(); } I get no error on socket connect, but the problem is that I always get returned that 4 bytes were written and the php server crashes with the error: "Connection reset by peer". The server works ok in other instances, as I am able to connect to it using telnet and I get the messages echoed. I think the issue is that I don't understand very well how to use the sockets from booster library and I would kindly ask you for an link where I can see a simple example or if you can provide some tips. Also, I have looked at the echo_server example but it's quite complicated and I want to test a simple client initially. Thank you, -- Fatol Sergiu Adrian Team Leader & Senior PHP Developer Arobs Transilvania Software *adi...@ar...* |
|
From: Lee E. <lee...@gm...> - 2013-01-10 08:20:00
|
ok allow me to elaborate
my map real code is like below - but the simple code i posted earlier
duplicates it as well
struct my_struct;
namespace cppcms {
namespace json {
struct traits<my_struct> {
static my_struct get(const value& val) {
...
}
static void set(value& v, const my_struct& m) {
...
}
};
template<typename V>
struct traits<std::map<std::string,V> > {
static std::map<std::string,V> get(const value& val) {
...
}
static void set(value& v, const std::map<std::string,V> m) {
auto o = v.object(); <-- attemp to make sure the
returned json is an object even if the map is empty
for(auto p : m)
o[p.first]=value(p.second);
}
}
};
} // namespace json
} // namespace cppcms
map<string, my_struct> m;
...
json::value v(m);
so i try to generate a new json object from my own map with json traits
defined for it
i get the exception on the o definition - and since v is an object i just
created is has to be undefined - i want the traits to change it to become
object
using the loop:
for(auto p : m)
v.set(p.first,p.second);
was my original code - this results in the same exception if there is some
data in the map, and returns an undefined object in case the map is empty
On Thu, Jan 10, 2013 at 2:42 AM, kpeo <sla...@ya...> wrote:
> P.S. Also, in general, as i understand it, your code doesn't change
> anything in "set" function.
> And you can also set default value in "get" function for passing undefined
> values:
>
>
> namespace cppcms {
> namespace json {
>
> template<typename V>
> struct traits<std::map<std::string,V> > {
> static std::map<std::string,V> get(const value& val) {
> std::map<std::string,V> m;
>
> for(auto p : val.object())
> m[p.first]=traits<V>::get(p.second,V()); // <-- set
> constructor as default for undefined values
>
>
> return m;
> }
> static void set(value& v, const std::map<std::string,V> m) {
> if(!v.is_undefined()){
>
> for(auto p : m)
> v.set(p.first,value(p.second)); // <-- set
> values with map ones (for example, so verify this code for your real app's
> needs)
>
> }
> }
> };
>
> } // namespace json
> } // namespace cppcms
>
> Regards,
> kpeo
>
> 10.01.2013, 02:48, "Lee Elenbaas" <lee...@gm...>:
>
> can anyone point me to what i did wrong in this code:
>
>
> namespace cppcms {
> namespace json {
>
> template<typename V>
> struct traits<std::map<std::string,V>> {
> static std::map<std::string,V> get(const value& val) {
> std::map<std::string,V> m;
>
> for(auto p : val.object())
> m[p.first]=traits<V>::get(p.second);
>
> return m;
> }
> static void set(value& v, const std::map<std::string,V> m) {
> auto o = v.object();
>
> for(auto p : m) {
> o[p.first]=value(p.second);
> }
> }
> };
>
> } // namespace json
> } // namespace cppcms
>
> when i try to use this:
>
> std::map<string, cppcms::json::value> m;
> ...
> cppcms::json::value v(m);
>
> i get the bad_value_cast exception
>
> thanks
> lee
>
> --
> --
> lee
> Lee Elenbaas
> lee...@gm...
> ,
>
>
> ------------------------------------------------------------------------------
> Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
> and much more. Keep your Java skills current with LearnJavaNow -
> 200+ hours of step-by-step video tutorials by Java experts.
> SALE $49.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122612
> ,
>
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
--
--
lee
Lee Elenbaas
lee...@gm...
|
|
From: kpeo <sla...@ya...> - 2013-01-10 00:42:24
|
<div>P.S. Also, in general, as i understand it, your code doesn't change anything in "set" function. <br />And you can also set default value in "get" function for passing undefined values:<br /><br />namespace cppcms {<br /> namespace json {<br /><br /> template<typename V><br /> struct traits<std::map<std::string,V> > {<br /> static std::map<std::string,V> get(const value& val) {<br /> std::map<std::string,V> m;<br /> <br /> for(auto p : val.object())<br /> m[p.first]=traits<V>::get(p.second,V()); // <-- set constructor as default for undefined values<br /> <br /> return m;<br /> }<br /> static void set(value& v, const std::map<std::string,V> m) {<br /> if(!v.is_undefined()){<br /><br /> for(auto p : m)<br /> v.set(p.first,value(p.second)); // <-- set values with map ones (for example, so verify this code for your real app's needs)<br /> }<br /> }<br /> };<br /><br /> } // namespace json<br />} // namespace cppcms</div><div><br />Regards,<br />kpeo<br /><br /></div><div>10.01.2013, 02:48, "Lee Elenbaas" <lee...@gm...>:</div><blockquote><div dir="ltr"><div>can anyone point me to what i did wrong in this code:<br /><br />namespace cppcms {<br /> namespace json {<br /><br /> template<typename V><br /> struct traits<std::map<std::string,V>> {<br /> static std::map<std::string,V> get(const value& val) {<br /> std::map<std::string,V> m;<br /> <br /> for(auto p : val.object())<br /> m[p.first]=traits<V>::get(p.second);<br /> <br /> return m;<br /> }<br /> static void set(value& v, const std::map<std::string,V> m) {<br /> auto o = v.object();<br /><br /> for(auto p : m) {<br /> o[p.first]=value(p.second);<br /> }<br /> }<br /> };<br /><br /> } // namespace json<br />} // namespace cppcms<br /><br /></div><div>when i try to use this:<br /><br /></div><div>std::map<string, cppcms::json::value> m;<br /> ...</div><div>cppcms::json::value v(m);<br /><br /></div><div>i get the bad_value_cast exception<br /><br /></div>thanks<br />lee<br clear="all" /><div><div><br />-- <br />--<br />lee<br />Lee Elenbaas<br /><a href="mailto:lee...@gm...">lee...@gm...</a></div></div></div>,<p>------------------------------------------------------------------------------<br />Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery<br />and much more. Keep your Java skills current with LearnJavaNow -<br />200+ hours of step-by-step video tutorials by Java experts.<br />SALE $49.99 this month only -- learn more at:<br /><a href="http://p.sf.net/sfu/learnmore_122612">http://p.sf.net/sfu/learnmore_122612</a> </p>,<p>_______________________________________________<br />Cppcms-users mailing list<br /><a href="mailto:Cpp...@li...">Cpp...@li...</a><br /><a href="https://lists.sourceforge.net/lists/listinfo/cppcms-users">https://lists.sourceforge.net/lists/listinfo/cppcms-users</a></p></blockquote> |
|
From: Daniel V. <chi...@gm...> - 2013-01-10 00:41:30
|
Try with cppcms::json::object instead of std::map<string,
cppcms::json::value>.
On Wed, Jan 9, 2013 at 8:47 PM, Lee Elenbaas <lee...@gm...> wrote:
> can anyone point me to what i did wrong in this code:
>
> namespace cppcms {
> namespace json {
>
> template<typename V>
> struct traits<std::map<std::string,V>> {
> static std::map<std::string,V> get(const value& val) {
> std::map<std::string,V> m;
>
> for(auto p : val.object())
> m[p.first]=traits<V>::get(p.second);
>
> return m;
> }
> static void set(value& v, const std::map<std::string,V> m) {
> auto o = v.object();
>
> for(auto p : m) {
> o[p.first]=value(p.second);
> }
> }
> };
>
> } // namespace json
> } // namespace cppcms
>
> when i try to use this:
>
> std::map<string, cppcms::json::value> m;
> ...
> cppcms::json::value v(m);
>
> i get the bad_value_cast exception
>
> thanks
> lee
>
> --
> --
> lee
> Lee Elenbaas
> lee...@gm...
>
>
> ------------------------------------------------------------------------------
> Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
> and much more. Keep your Java skills current with LearnJavaNow -
> 200+ hours of step-by-step video tutorials by Java experts.
> SALE $49.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122612
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
|
|
From: kpeo <sla...@ya...> - 2013-01-10 00:12:15
|
<div>Hi,<br />I think, you should handle undefined values.</div><div>Excepion on row:</div><div> auto o = v.object();<br />, where v is undefined yet.</div><div> </div><div>So this code works:</div><div> static void set(value& v, const std::map<std::string,V> m) {</div><div> if(!v.is_undefined()){<br /> auto o = v.object();<br /><br /> for(auto p : m)<br /> o[p.first]=value(p.second);</div><div> }//if<br /> }//set</div><div> </div><div>10.01.2013, 02:48, "Lee Elenbaas" <lee...@gm...>:</div><blockquote><div dir="ltr"><div>can anyone point me to what i did wrong in this code:<br /><br />namespace cppcms {<br /> namespace json {<br /><br /> template<typename V><br /> struct traits<std::map<std::string,V>> {<br /> static std::map<std::string,V> get(const value& val) {<br /> std::map<std::string,V> m;<br /> <br /> for(auto p : val.object())<br /> m[p.first]=traits<V>::get(p.second);<br /> <br /> return m;<br /> }<br /> static void set(value& v, const std::map<std::string,V> m) {<br /> auto o = v.object();<br /><br /> for(auto p : m) {<br /> o[p.first]=value(p.second);<br /> }<br /> }<br /> };<br /><br /> } // namespace json<br />} // namespace cppcms<br /><br /></div><div>when i try to use this:<br /><br /></div><div>std::map<string, cppcms::json::value> m;<br /> ...</div><div>cppcms::json::value v(m);<br /><br /></div><div>i get the bad_value_cast exception<br /><br /></div>thanks<br />lee<br clear="all" /><div><div><br />-- <br />--<br />lee<br />Lee Elenbaas<br /><a href="mailto:lee...@gm...">lee...@gm...</a></div></div></div>,<p>------------------------------------------------------------------------------<br />Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery<br />and much more. Keep your Java skills current with LearnJavaNow -<br />200+ hours of step-by-step video tutorials by Java experts.<br />SALE $49.99 this month only -- learn more at:<br /><a href="http://p.sf.net/sfu/learnmore_122612">http://p.sf.net/sfu/learnmore_122612</a> </p>,<p>_______________________________________________<br />Cppcms-users mailing list<br /><a href="mailto:Cpp...@li...">Cpp...@li...</a><br /><a href="https://lists.sourceforge.net/lists/listinfo/cppcms-users">https://lists.sourceforge.net/lists/listinfo/cppcms-users</a></p></blockquote> |
|
From: Lee E. <lee...@gm...> - 2013-01-09 22:48:09
|
can anyone point me to what i did wrong in this code:
namespace cppcms {
namespace json {
template<typename V>
struct traits<std::map<std::string,V>> {
static std::map<std::string,V> get(const value& val) {
std::map<std::string,V> m;
for(auto p : val.object())
m[p.first]=traits<V>::get(p.second);
return m;
}
static void set(value& v, const std::map<std::string,V> m) {
auto o = v.object();
for(auto p : m) {
o[p.first]=value(p.second);
}
}
};
} // namespace json
} // namespace cppcms
when i try to use this:
std::map<string, cppcms::json::value> m;
...
cppcms::json::value v(m);
i get the bad_value_cast exception
thanks
lee
--
--
lee
Lee Elenbaas
lee...@gm...
|