cppcms-users Mailing List for CppCMS C++ Web Framework (Page 28)
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
|
From: mawan s. <ma...@gm...> - 2015-09-30 06:38:25
|
Thankyou Kpeo I now understand that it is depend my application for json rpc or web application. Thanks for your response. On Wed, Sep 30, 2015 at 1:08 PM, kpeo <sla...@ya...> wrote: > Hi! > > It depends on your application and goals. > > The JSON-RPC server (asynchronous application) could be smoothly combined > with synchronous application. See: > http://permalink.gmane.org/gmane.comp.lib.cppcms.user/580 > http://cppcms.com/wikipp/en/page/cppcms_1x_json_rpc > If you mean conversion from cppcms::json::value to string/stream/etc. - > you can write something like > > std::string json_to_string(cppcms::json::value const& v) > { > std::ostringstream ss; > if(!v.is_undefined()) > ss << v; > return ss.str(); > } > > For json_rpc - you can just return the cppcms::json::value (i.e. "v"), > like: > return_result(v); > > Also you can look at examples/json_rpc_chat/chat.cpp and > test/jsonrpc_test.cpp from CppCMS sources. > > Best regards, > kpeo > > 30.09.2015, 06:18, "mawan sugiyanto" <ma...@gm...>: > > Dear All > > how to create json output .. > > I have an alternatives for json ouput .. create json value and then ouput > to the response > or any other best way to create json ouput? > > or it have to create rpc server, how if it combile with web application? > > thanks .. > > , > > > ------------------------------------------------------------------------------ > , > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |
From: kpeo <sla...@ya...> - 2015-09-30 06:24:17
|
<p>Hi!</p><p>It depends on your application and goals.<br /><br />The JSON-RPC server (asynchronous application) could be smoothly combined with synchronous application. See:<br /><a href="http://permalink.gmane.org/gmane.comp.lib.cppcms.user/580">http://permalink.gmane.org/gmane.comp.lib.cppcms.user/580</a><br /><a href="http://cppcms.com/wikipp/en/page/cppcms_1x_json_rpc">http://cppcms.com/wikipp/en/page/cppcms_1x_json_rpc</a></p><div>If you mean conversion from cppcms::json::value to string/stream/etc. - you can write something like</div><p>std::string json_to_string(cppcms::json::value const& v)<br />{<br /> std::ostringstream ss;<br /> if(!v.is_undefined())<br /> ss << v;<br /> return ss.str();<br />}</p><p>For json_rpc - you can just return the cppcms::json::value (i.e. "v"), like: <br />return_result(v);<br /><br /></p><div>Also you can look at examples/json_rpc_chat/chat.cpp and test/jsonrpc_test.cpp from CppCMS sources.</div><div><br />Best regards,<br />kpeo</div><p>30.09.2015, 06:18, "mawan sugiyanto" <<a href="mailto:ma...@gm...">ma...@gm...</a>>:</p><blockquote> Dear All<br /><br /> how to create json output ..<br /><br /> I have an alternatives for json ouput .. create json value and then ouput to the response<br /> or any other best way to create json ouput?<br /><br /> or it have to create rpc server, how if it combile with web application?<br /><br /> thanks ..<br /><br /> ,<br /><br /> ------------------------------------------------------------------------------<br /> ,<br /><br /> _______________________________________________<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></blockquote> |
From: mawan s. <ma...@gm...> - 2015-09-30 03:17:44
|
Dear All how to create json output .. I have an alternatives for json ouput .. create json value and then ouput to the response or any other best way to create json ouput? or it have to create rpc server, how if it combile with web application? thanks .. |
From: CN <cn...@fa...> - 2015-09-30 02:48:16
|
Correct the typo in previous message. On Wed, Sep 30, 2015, at 10:37 AM, CN wrote: > cppcms::service *service; > void signal_handler(int signal_number) > { > service->shutdown(); > } > cppcms::service *service; int caught_signal=0; void signal_handler(int signal_number) { caught_signal=signal_number; service->shutdown(); } -- http://www.fastmail.com - The professional email service |
From: CN <cn...@fa...> - 2015-09-30 02:37:39
|
The following program does not terminate until 10 seconds has passed. I want to terminate it immediately once I type "kill -SIGTERM". Is that possible? How do I achieve that? ------- class MyClass { private: booster::aio::io_service &io_service; booster::aio::deadline_timer timer; public: MyClass(booster::aio::io_service &io_service) : io_service(io_service),timer(io_service){} void start() { io_service.set_timer_event(booster::ptime::now(),boost::bind(&MyClass::work,this,_1)); io_service.run(); } void work(booster::system::error_code const &e) { if(e) return; //do_my_job(); Do periodic job here. timer.expires_from_now(booster::ptime::seconds(10); timer.async_wait(boost::bind(&MyClass::work,this,_1)); } void stop() { io_service.stop(); } }; cppcms::service *service; void signal_handler(int signal_number) { service->shutdown(); } int main(int argc,char **argv) { //init_signal_trap(); Initialize signal trap here. while(true){ service=new cppcms::service(argc,argv); service->applications_pool().mount(cppcms::applications_factory<my_app>(),cppcms::mount_point(".*",1)); booster::shared_ptr<MyClass> mc(new MyClass(service->get_io_service())); booster::thread t(boost::bind(&MyClass::start,mc)); service->run(); //Type "kill -SIGTERM" in OS so that signal_handler() gets called here. mc->stop(); t.join(); //Program does not reach here until 10 seconds passes! if(caught_signal > 0){ switch (caught_signal){ case 1: //SIGHUP case 14:{ //SIGALRM //Restart application. caught_signal=0; break; } default:{ //Terminate program. //case 2: //SIGINT //case 15: //SIGTERM //caught_signal=0; return 0; } } //switch } //if } //while } ------- Best Regards, CN -- http://www.fastmail.com - The way an email service should be |
From: mawan s. <ma...@gm...> - 2015-09-29 11:28:53
|
Dear All Please help me, how to create form dynamic from the controller. I have read from this url http://cppcms.com/wikipp/en/page/ref_cppcms_forms#dyn about dynamic url , but it is not clearly .. please how to build form like array form for multiple input. Thanks |
From: augustin <aug...@ov...> - 2015-09-22 04:19:24
|
On Saturday, September 19, 2015 03:22:16 AM Artyom Beilis wrote: > Several points: > (a) You misunderstand meaning of "raw" output - "raw" means you are sending > CGI output including headers etc on your own and CppCMS does not interfere > with it. There only very-very specific cases you may actually need this - > bottom line you don't need it. Ok. I had been struggling with my problem for a few days before I asked, and I was trying to eliminate all possible sources of corruption. I had come to the conclusion that this probably was not it. Thanks for confirming it. > (b) std::ostream is just a character or more > correctly octet stream, std::string is a container that keeps bytes/"C > chars"/octets in it in string friendly way. You can put any binary data to > it. > Now in your case the problem is there app()->response().out() << buf << std::flush; > or cppcms_buf << buf > > Why? std::ostream assumes that buf is NUL terminated string so it would > stop on NUL, and this what corrupts the stream.You need to use > std::ostream::write, i.e. out().write(buf,siz) > That's it > > Artyom Beilis Thank you Artyom! You clearly saw the source of the problem. Joerg also gave me a hint earlier which pointed me in the right direction. I had searched online and found other newbies like me who made the same wrong assumption about the << operator, which, I understand now, should not be used for binary streams. After reading your mail, I still struggled for a while with type casting. I had compile errors such as: error: invalid conversion from 'HPDF_BYTE*' to 'const char*' or: error: invalid static_cast from type 'HPDF_BYTE [4096]' to type 'const char*' Finally, I was forced to use a reinterpret_cast, but apparently it cannot be avoided: // #include <hpdf.h> typedef unsigned char HPDF_BYTE; // my_pdf.cpp: // Create PDF. HPDF_Doc pdf = HPDF_New(pdf::error_handler, NULL); .... .... // Add content to pdf. .... HPDF_SaveToStream (pdf); for (;;) { HPDF_BYTE buf[4096]; HPDF_UINT32 siz = 4096; HPDF_ReadFromStream (pdf, buf, &siz); // cppcms::http::response: app()->response().out().write(reinterpret_cast<const char*>(buf), siz); if (siz == 0) break; } app()->response().out() << std::flush; HPDF_Free(pdf); I am not sure if the << std::flush at the end is necessary, but it doesn't seem to hurt. Artyom, would you like me to create a simple tutorial on using cppcms + libharu on the cppcms wiki? Do you think it may be useful to other people? I can do it if you wish. On Saturday, September 19, 2015 03:26:34 AM Artyom Beilis wrote: > As BTW is shown in this > example: http://libharu.sourceforge.net/how_to_use.html#Save_a_document_to_file_ Yes, I had already seen that page. Actually, the project has moved to github, so I was following the corresponding page there: https://github.com/libharu/libharu/wiki/Usage-examples My main problem is lack of experience (I don't code full time) and I am still baffled by some intricacies of the language and the standard libraries. I often fail to see the relevance of what I am reading to my problem. Once I have solved a problem, it is often frustrating to see that I had actually come across the solution days earlier but failed to understand it! Believe me, I don't take free online help for granted. I always ask as a last resort, when I feel really stuck after having spent a few days trying to fully understand the problem and researching online. As always, I am grateful for you help, and I am in awe of your mastery of the language! :) Blessings, augustin. |
From: Joerg S. <jo...@br...> - 2015-09-20 17:12:34
|
On Fri, Sep 18, 2015 at 07:22:16PM +0000, Artyom Beilis wrote: > Several points: > (a) You misunderstand meaning of "raw" output - "raw" means you are sending CGI output including headers etc on your own and CppCMS does not interfere with it. There only very-very specific cases you may actually need this - bottom line you don't need it.(b) std::ostream is just a character or more correctly octet stream, std::string is a container that keeps bytes/"C chars"/octets in it in string friendly way. You can put any binary data to it. > Now in your case the problem is there" > app()->response().out() << buf << std::flush; or > cppcms_buf << buf > > Why? std::ostream assumes that buf is NUL terminated string so it would stop on NUL, and this what corrupts the stream.You need to use std::ostream::write, i.e. > out().write(buf,siz) Depends on the type of buf. If it is a std::string, it should work fine? That said, I have no idea what overloading the other library provides. Joerg |
From: Artyom B. <art...@ya...> - 2015-09-18 19:27:26
|
As BTW is shown in this example: http://libharu.sourceforge.net/how_to_use.html#Save_a_document_to_file_ Why? std::ostream assumes that buf is NUL terminated string so it would stop on NUL, and this what corrupts the stream. You need to use std::ostream::write, i.e. out().write(buf,siz) |
From: Artyom B. <art...@ya...> - 2015-09-18 19:22:24
|
Several points: (a) You misunderstand meaning of "raw" output - "raw" means you are sending CGI output including headers etc on your own and CppCMS does not interfere with it. There only very-very specific cases you may actually need this - bottom line you don't need it.(b) std::ostream is just a character or more correctly octet stream, std::string is a container that keeps bytes/"C chars"/octets in it in string friendly way. You can put any binary data to it. Now in your case the problem is there" app()->response().out() << buf << std::flush; or cppcms_buf << buf Why? std::ostream assumes that buf is NUL terminated string so it would stop on NUL, and this what corrupts the stream.You need to use std::ostream::write, i.e. out().write(buf,siz) That's it Artyom Beilis From: augustin <aug...@ov...> To: cpp...@li... Sent: Thursday, September 17, 2015 4:16 PM Subject: Re: [Cppcms-users] HTTP response and binary stream (libharu) On Thursday, September 17, 2015 07:07:21 PM Joerg Sonnenberger wrote: > On Thu, Sep 17, 2015 at 05:52:03PM +0800, augustin wrote: > > I am trying to get my cppcms application to output a PDF file (using > > libharu). However, I seem to have a problem returning the binary output. > > It seems that the cppcms internals are corrupting the stream. > > Works fine for me, but I don't set raw mode or anything like that, just: > > response().content_type("application/pdf"); > response().out() << pdf; > > where pdf is a std::string. Thanks, but pdf is not a std::string. It is a HPDF_Doc from the libharu library, which is used to create documents following the PDF standard. A PDF file may include binary streams. I have no problem outputting HTML (std::string). I have no problem outputting simple PDF files which only include a stream of strings. But when I try creating more complex PDF files with drawings or pictures (i.e. PDF files including binary streams), the file gets corrupted and is not rendered properly. Right now, I am learning about the complexities of having binary streams in C++. There are quite a few articles on the topic on the internet. My main question is: is it a problem in my own code, or is it a shortcoming of the cppcms library, that it cannot handle binary streams? Does cppcms need to be patched or should I handle the stream differently on my end? thanks, augustin. ------------------------------------------------------------------------------ Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place. SourceForge users - Click here to start your Free Trial of Datadog now! http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom B. <art...@ya...> - 2015-09-18 19:10:39
|
assert_on_sqlwchar_is_16 is caused when the ODBC library you are compiling against isn't complying with ODBC API standard.ODBC uses/requires wide API to with with UTF-16. AFAIR iODBC usually causes this problem, try to compile against unixodbc Artyom Beilis From: mawan sugiyanto <ma...@gm...> To: cpp...@li... Sent: Thursday, September 17, 2015 11:29 AM Subject: [Cppcms-users] cppdb on mac os Dear Members I am new in this group. I want to ask you about how to compile cppdb on Mac OS X. This is my error message on command line Performing Test CPPDB_HAVE_MAC_OS_X_ATOMIC - Success-- libpq not found, disableing postgresql backend-- mysqlclient not found, disableing mysql backend-- Configuring doneCMake Warning (dev): Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake --help-policy CMP0042" for policy details. Use the cmake_policy command to set the policy and suppress this warning. MACOSX_RPATH is not specified for the following targets: cppdb cppdb_sqlite3 This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done-- Build files have been written to: /Users/mawansugiyanto/Master/MASTER_B/CPP/cppdb-0.3.1/buildMawans-iMac:build mawansugiyanto$ sudo makeScanning dependencies of target cppdb[ 2%] Building CXX object CMakeFiles/cppdb.dir/drivers/odbc_backend.cpp.o/Users/mawansugiyanto/Master/MASTER_B/CPP/cppdb-0.3.1/drivers/odbc_backend.cpp:46:30: error: 'assert_on_sqlwchar_is_16' declared as an array with a negative size Thanks Mawan ------------------------------------------------------------------------------ Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place. SourceForge users - Click here to start your Free Trial of Datadog now! http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Joerg S. <jo...@br...> - 2015-09-18 09:28:52
|
On Fri, Sep 18, 2015 at 04:53:24PM +0800, augustin wrote: > Do your pdf contain only plain text, or do they contain graphics? Embedded fonts, so it would definitely and visibly fail. > Can you post a simple hello_world.pdf code, especially the part where the > generated PDF is sent back via the cppcms output stream: > cppcms::http::response().out() > ? On Sunday, if I remember. > I hesitated between using libharu and PoDoFo. > Neither library is well documented. > I just started with libharu but it's not too late to switch to another > library. > Are you happy with PoDoFo? It could do everything I wanted so far, even though some parts were a bit tricky to get work between pdfJS limitations, the sometimes incomprehensible PDF reference and figuring out the mechanics of PoDoFo. But I don't think a different library would have made things much easier. Joerg |
From: mawan s. <ma...@gm...> - 2015-09-18 09:13:08
|
Dear All I need your help, how to compile cppcms in Mac OS X? Thankyou before. Mawan |
From: augustin <aug...@ov...> - 2015-09-18 08:53:40
|
On Thursday, September 17, 2015 09:46:41 PM Joerg Sonnenberger wrote: > On Thu, Sep 17, 2015 at 09:16:42PM +0800, augustin wrote: > > I have no problem outputting HTML (std::string). > > I have no problem outputting simple PDF files which only include a stream > > of strings. > > But when I try creating more complex PDF files with drawings or pictures > > (i.e. PDF files including binary streams), the file gets corrupted and > > is not rendered properly. > > Try creating a std::stringstream with std::ios::binary and write to that > from your library. That's what I'm already doing. From the code I posted at the beginning: std::ostringstream cppcms_buf(std::ios::binary); ... // cppcms::http::response: app()->response().out() << cppcms_buf.str(); > Use the stringstream -> string accessor and write > that. That's what I am doing when creating PDFs from PoDoFo. Do your pdf contain only plain text, or do they contain graphics? Can you post a simple hello_world.pdf code, especially the part where the generated PDF is sent back via the cppcms output stream: cppcms::http::response().out() ? I hesitated between using libharu and PoDoFo. Neither library is well documented. I just started with libharu but it's not too late to switch to another library. Are you happy with PoDoFo? Thank you, Joerg. augustin. . |
From: augustin <aug...@ov...> - 2015-09-18 08:44:05
|
On Thursday, September 17, 2015 11:58:48 PM Marcel Hellwig wrote: > you could and/or should (depending on what are you trying to do) return > a base64 encoded string. Thanks Joerg and Marcel, you open new avenues of investigation for me. I've just been researching the base64 solution, and I fail to see where to employ it and how it would solve the problem. First, the HTTP protocol does not use base64 encoding. It supports binary streams natively (how else would pictures and what not be transferred?). As far as I am aware, Base64 was/is mostly used for mail transport. Secondly, unless I missed it, the PDF protocol does not support base64 encoded PDF files. I cannot find any information about this. What am I trying to do? Create within my cppcms application a PDF document on the fly (dynamically), and return a proper .pdf file to the user via cppcms and the HTTP protocol. As far as I am aware, the problem is either within my cppcms application or within cppcms itself. My experience is limited, and I may be missing something, but I fail to see at what stage to use Base64 strings and how it would help. I'm still looking and testing... Cheers, augustin. . |
From: Marcel H. <ke...@co...> - 2015-09-17 16:15:05
|
On 17.09.2015 15:16, augustin wrote: > Thanks, but pdf is not a std::string. you could and/or should (depending on what are you trying to do) return a base64 encoded string. |
From: Joerg S. <jo...@br...> - 2015-09-17 13:46:51
|
On Thu, Sep 17, 2015 at 09:16:42PM +0800, augustin wrote: > I have no problem outputting HTML (std::string). > I have no problem outputting simple PDF files which only include a stream of > strings. > But when I try creating more complex PDF files with drawings or pictures (i.e. > PDF files including binary streams), the file gets corrupted and is not > rendered properly. Try creating a std::stringstream with std::ios::binary and write to that from your library. Use the stringstream -> string accessor and write that. That's what I am doing when creating PDFs from PoDoFo. Whether the default streams should be created as binary is a slightly different question. Joerg |
From: augustin <aug...@ov...> - 2015-09-17 13:17:02
|
On Thursday, September 17, 2015 07:07:21 PM Joerg Sonnenberger wrote: > On Thu, Sep 17, 2015 at 05:52:03PM +0800, augustin wrote: > > I am trying to get my cppcms application to output a PDF file (using > > libharu). However, I seem to have a problem returning the binary output. > > It seems that the cppcms internals are corrupting the stream. > > Works fine for me, but I don't set raw mode or anything like that, just: > > response().content_type("application/pdf"); > response().out() << pdf; > > where pdf is a std::string. Thanks, but pdf is not a std::string. It is a HPDF_Doc from the libharu library, which is used to create documents following the PDF standard. A PDF file may include binary streams. I have no problem outputting HTML (std::string). I have no problem outputting simple PDF files which only include a stream of strings. But when I try creating more complex PDF files with drawings or pictures (i.e. PDF files including binary streams), the file gets corrupted and is not rendered properly. Right now, I am learning about the complexities of having binary streams in C++. There are quite a few articles on the topic on the internet. My main question is: is it a problem in my own code, or is it a shortcoming of the cppcms library, that it cannot handle binary streams? Does cppcms need to be patched or should I handle the stream differently on my end? thanks, augustin. |
From: Joerg S. <jo...@br...> - 2015-09-17 11:20:35
|
On Thu, Sep 17, 2015 at 05:52:03PM +0800, augustin wrote: > I am trying to get my cppcms application to output a PDF file (using libharu). > However, I seem to have a problem returning the binary output. > It seems that the cppcms internals are corrupting the stream. Works fine for me, but I don't set raw mode or anything like that, just: response().content_type("application/pdf"); response().out() << pdf; where pdf is a std::string. Joerg |
From: augustin <aug...@ov...> - 2015-09-17 10:09:30
|
Hello, I am asking here about returning a stream of data representing a PDF document. I could ask the same question about returning a dynamically generated image, using a third party library but returning the image with a cppcms application. I am trying to get my cppcms application to output a PDF file (using libharu). However, I seem to have a problem returning the binary output. It seems that the cppcms internals are corrupting the stream. I have tested separately libharu and it works Ok. When I integrate the code into my cppcms application, I get a corrupted file. I am not sure which way exist to return a // Raw mode, returning simple HTTP headers: app()->response().io_mode(cppcms::http::response::io_mode_type::raw); // content type: PDF. app()->response().out() << "Content-type: application/pdf\r\n"; app()->response().out() << "\r\n"; HPDF_Doc pdf // Create new PDF object. HPDF_SaveToStream (pdf); std::ostringstream cppcms_buf(std::ios::binary); cppcms_buf.imbue(app()->context().locale()); for (;;) { HPDF_BYTE buf[4096]; HPDF_UINT32 siz = 4096; HPDF_ReadFromStream (pdf, buf, &siz); //app()->response().out() << buf << std::flush; if (siz == 0) break; cppcms_buf << buf; } // Getting a cppcms::http::response: app()->response().out() << cppcms_buf.str(); I don't know if Artyom is still maintaining this project. I hope that either he or someone else can tell me whether it's possible. thanks, augustin. |
From: mawan s. <ma...@gm...> - 2015-09-17 08:30:08
|
Dear Members I am new in this group. I want to ask you about how to compile cppdb on Mac OS X. This is my error message on command line Performing Test CPPDB_HAVE_MAC_OS_X_ATOMIC - Success -- libpq not found, disableing postgresql backend -- mysqlclient not found, disableing mysql backend -- Configuring done CMake Warning (dev): Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake --help-policy CMP0042" for policy details. Use the cmake_policy command to set the policy and suppress this warning. MACOSX_RPATH is not specified for the following targets: cppdb cppdb_sqlite3 This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done -- Build files have been written to: /Users/mawansugiyanto/Master/MASTER_B/CPP/cppdb-0.3.1/build Mawans-iMac:build mawansugiyanto$ sudo make *Scanning dependencies of target cppdb* [ 2%] Building CXX object CMakeFiles/cppdb.dir/drivers/odbc_backend.cpp.o */Users/mawansugiyanto/Master/MASTER_B/CPP/cppdb-0.3.1/drivers/odbc_backend.cpp:46:30: **error: **'assert_on_sqlwchar_is_16' declared as an* * array with a negative size* *Thanks * *Mawan* |
From: Lederhilger M. <M.L...@ds...> - 2015-07-23 14:49:07
|
Hello, when initializing a JSON value, wouldn't it be better to directly initialize the Boost variant (faster), instead of default initializing and later assigning it - somehow like in the attachment. Greetings, Martin |
From: Artyom B. <art...@ya...> - 2015-07-16 15:53:37
|
1st Have you tried to use internal pooling. i.e. just sql("mysql:options=a;@pool_size=10") It allows you not to deal with pool object on your own.Do you close or destroy sql connection after you use (it would return the connection to the pool) Regarding your way of doing things have you tried to check with the debugger what exactly returns the error?Because it does not seems to be pooling related error. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ From: Alexander Mack <a....@ev...> To: cpp...@li... Sent: Thursday, July 16, 2015 12:48 PM Subject: [Cppcms-users] Connection errors while using connection pool in multithreading programms (beside cppcms) Hello Artyom, Hello Community, I'm testing cppdb as db-interface for a "non-cppcms" program. At the start of the program, I'm creating a global cppdb pool using the following command: // Create the pool cppdb::pool::pointer my_pool = cppdb::pool::create("sqlite3:db=test.db"); After that, I'm starting some threads. Each thread is trying to create a cppdb::session using the following command and doing some commands on the db: // Use the pool cppdb::session sql(my_pool->open()); sql.once(...); // doing some config sql << ... // using session / doing some stuff on db.. If I'm "deactivating" the multithreading it works fine (I'm join()ing the threads directly after creating them). As soon as I'm trying to run more than one thread at the same time, only the first thread works fine.. Each following thread throws a "cppdb::mysql::Can't connect to MySQL server on 'localhost' (111)" exceptions. I already checked my mysql settings (e.g. max connections) and they are set on 500. Has someone of you tried to do the same and got the same issues? I'm happy about every hint :-) Thank you very much, Alex ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Alexander M. <a....@ev...> - 2015-07-16 10:01:47
|
Hello Artyom, Hello Community, I'm testing cppdb as db-interface for a "non-cppcms" program. At the start of the program, I'm creating a global cppdb pool using the following command: // Create the pool cppdb::pool::pointer <http://cppcms.com/sql/cppdb/classcppdb_1_1ref__ptr.html> my_pool =cppdb::pool::create <http://cppcms.com/sql/cppdb/classcppdb_1_1pool.html#a5f0d996be0a4da7750edb2c00d3f6a78>("sqlite3:db=test.db"); After that, I'm starting some threads. Each thread is trying to create a cppdb::session using the following command and doing some commands on the db: // Use the pool cppdb::session <http://cppcms.com/sql/cppdb/classcppdb_1_1session.html> sql(my_pool->open <http://cppcms.com/sql/cppdb/classcppdb_1_1pool.html#aae9914b4323d982c49c4604b0696ecb0>()); sql.once(...); // doing some config sql << ... // using session / doing some stuff on db.. If I'm "deactivating" the multithreading it works fine (I'm join()ing the threads directly after creating them). As soon as I'm trying to run more than one thread at the same time, only the first thread works fine.. Each following thread throws a "cppdb::mysql::Can't connect to MySQL server on 'localhost' (111)" exceptions. I already checked my mysql settings (e.g. max connections) and they are set on 500. Has someone of you tried to do the same and got the same issues? I'm happy about every hint :-) Thank you very much, Alex |
From: Joerg S. <jo...@br...> - 2015-07-05 09:26:17
|
On Sun, Jul 05, 2015 at 01:32:02PM +0900, redred77 wrote: > I think you over trusted compiler's inline function. > They do their best, but they can't skip making temporary objects. Well, the temporary object is a slightly different question. That's a result of the out-of-line definition. Why it is forcing that only Artyom can answer. Joerg |