ppC++(acronym for "ppC++ preprocessed C++"), is an HTML-preprocessed
C/C++ programming language. This preprocessor lets you write server-side
programs in C++ inside your HTML code and brings new additional features
which make web programming easier.
ppC++ was developed for those, who
need high performance, stability and harmony in simple HTML enviroment.
For those, who know C or C++ and have some skills in HTML, doesn't wish to
learn new interpreter languages like Perl, PHP or ASP and wants to start
creating dynamic web-pages immediately. If you are C/C++ programmer, you
would start to develop a full-featured dynamic server pages of full value
and ease of HTML tags in a few hours. The main goal of ppC++ is to bring
classic C/C++ adopted in simple and rapid development of dynamic
ppC++ lets you use powerfull, stable and fast C++ in simple
web scripts and hides a lot of routine cgi programming.
How does it work? Here is an example:
As you see, it looks like a regular HTML page, but you can find
one line written in C++ between special tags.
Now save this file somwhere in your cgi-bin directory
as, for example, "hello.ppc" and run it from
ppC++ web compiler or simply
type the script's path and name in your browser address
line(only in UNIX) - it will create
standalone cgi executable binary file "hello.ppc.cgi" in the
same directory that outputs to client browser:
"hello.ppc.cgi" is the independent compiled cgi-programm
and doesn't require neither its "ppc" source, nor ppC++ compiler.
And you don't have to worry if someone could download your original
source code - if client will request it, web-server will treat
ppc-source as an executable and will return 500 server error.
First you need to install web-server.
Apache >2.0 is the only server now that
supports ppC++(if somebody could cross it to other servers,
please let me know). If you don't know what is
web server and how to configure it, download one of easy-to-install
distributions of server, like
When you have configured and started your server,
go to download page.
·3.1 Functions, classes and global variables
Functions, classes and global variables can be declared anywhere,
for example in
addittional standard C++ header files, the same or the other ppc scripts,
and this constructions will be accessable anywhere in the script.
The simplest way is to write functions or classes in one file:
As it seen from example, the function can be declared after it
OK, the function works, but doesn't it look a
little cumbersome in this HTML enviroment? In this case ppC++ lets
you write much more grace code:
The same story about classes/structs:
To use global
variables or class/srtuct objects(those,
which must be accessible to functions or classes) you have to define
it with special keyword: global (it is sacrifice for
The variable must be defined as a global, for
example this will not work:
And of course you can use standard C/C++ library fuctions/classes -
simply by including their header files:
Preprocessor lets you include your own native C/C++ files:
·3.3 HTTP request variables(GET and POST)
Now we can write dynamic HTML pages, but how to make our pages
interactive? To use HTTP request variables, which can be sent to server via
"<form>" or URL HTTP request string.
When the following form is submitted
or "script.ppc.cgi?var1=value1&var2=value2" is requested,
ppC++ will create the variables "var1" and "var2" as members
of ppc - special pseudo class object, which hides and encapsulates
all the cgi routine work:
"Page2.ppc" shows the cookie value. If it is absent, an empty string
will be shown:
"Page3.ppc" also has an acces to cookie.foo:
To erease the cookie value, simply write
client browser will remove this variable.
Remember, the type of all the variables from "cookie"
return "string" type
, though it is actually
not string object - the string's common functions and properties are not
But if you will try to compile "second_file.ppc" alone, you
get a fatal error: variable "a" undeclared.
Included ppc files also can contain functions, structs and classes
in addition to main code, which
runs immediately. You can even include the same ppc file more than
once without expecting name conflicts:
Returns a string in which all non-alphanumeric characters except -_.
have been replaced with a percent (%) sign followed by two hex digits.
It is encoded the same way that the posted data from a WWW form is
· name - name of cookie.
· value - value of cookie.
· EXPIRES=date - the cookie will live until date.
By default cookie dies in the moment of browser closing.
· PATH=path - the path of cookies visibility.
· DOMAIN=domain_name - domain of cookies visibility.
· SECURE - shows if the cookie is sent via secure shell.