<?xml version="1.0" standalone="no"?>
<!--
* 
*
*  ProLinga-Calc
*
*  Copyright (C) 2002-2009 Xobas Software
*  All rights reserved.
*  
*  This file is part of ProLinga-Calc.
*
*  ProLinga-Calc is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  ProLinga-Calc is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with ProLinga-Calc. If not, see <http://www.gnu.org/licenses/>.
*
*  More information is available at the following addresses:
*
*  Website     : http://www.prolinga.org
*
*  Email       : prolinga-list@prolinga.org
*
*
-->

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [

<!ENTITY version "0.0.2" >
<!ENTITY release-date "August 23, 2009" >
<!ENTITY copyright-year "2009" >
<!ENTITY prolinga-calc-API  SYSTEM "prolinga-calc-API.xml" >
<!ENTITY prolinga-calc-userguide  SYSTEM "prolinga-calc-userguide.xml" >
<!ENTITY fdl  SYSTEM "fdl.xml" >
<!ENTITY PRODUCT "prolinga-calc" >
<!ENTITY xobas '<emphasis><ulink url="http://www.xobas.com">Xobas Software</ulink></emphasis>'>

]>

<book id="prolinga-calc" lang="en">
  <bookinfo>
    <title>ProLinga-Calc Project</title>
    <releaseinfo>Release: &PRODUCT;-&version; - &release-date;</releaseinfo>
    <authorgroup>
      <author>
	<firstname>Bas</firstname>
	<surname>Driessen</surname>
	<affiliation>
          <orgname>&xobas;</orgname>
	    <address><email>bas.driessen@xobas.com</email></address>
	</affiliation>
	<contrib>Original author and current maintainer.</contrib>
      </author>
    </authorgroup>

    <copyright>
      <year>2002-&copyright-year;</year>
      <holder>The ProLinga Team</holder>
    </copyright>

    <legalnotice>
      <para>Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.2
      or any later version published by the Free Software Foundation;
      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
      A copy of the license is included in the section entitled
      <ulink type="http"
      url="gfdl.html">"GNU Free Documentation License"</ulink>.</para>
    </legalnotice>

    <abstract>
      <para>This document describes the ProLinga-Calc Project, how to
      build the software components and documents the API reference of the 
      prolinga-calc library.</para>
    </abstract>
  </bookinfo>

  <chapter id="prolinga-calc-product-info">
    <title>ProLinga-Calc Project</title>

    <para>The ProLinga-Calc Project is a small project which focusses 
    on the development of 
    a library which, after implementing, enables any
    application to make C expression type calculations. Simple
    expressions as x=2+3 and more complicated ones like
    x=2*sin(y).</para>

    <para>Main purpose for the creation of this project, is to provide an
    easy way to perform calculations from the ProLinga 4GL programming 
    language. Since the result library of this project is very open, simple and 
    easy to implement, it can be used in other non-ProLinga related projects.</para>

    <para>Input for the ProLinga-Calc library are normal C expressions containing operators, float
    or integer constants, variables and references to previous results ($n).
    Precedence and semantic of operators is the same as in C language. There are
    two extra binary operators: &gt;&gt;&gt; unsigned shift right and ** raising to power.
    ProLinga-Calc supports the standard set of functions from C mathematics library and
    also defines function prime(n), which returns smallest prime number &gt;= n.</para>

    <para>Operators:</para>

    <itemizedlist>
       <listitem>
         <para><![CDATA[++ -- ! ~ unary + -]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[**]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[* / %]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[+ -]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[<< >> >>>]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[< <= > >=]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[== !=]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[&]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[^]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[|]]></para>
       </listitem>
       <listitem>
         <para><![CDATA[= += -= *= /= %= <<= >>= >>>= &= |= ^= **=]]></para>
       </listitem>
    </itemizedlist>

    <para>Functions:</para>

    <itemizedlist>
       <listitem>
         <para>abs</para>
       </listitem>
       <listitem>
         <para>acos</para>
       </listitem>
       <listitem>
         <para>asin</para>
       </listitem>
       <listitem>
         <para>atan</para>
       </listitem>
       <listitem>
         <para>atan2</para>
       </listitem>
       <listitem>
         <para>cos</para>
       </listitem>
       <listitem>
         <para>cosh</para>
       </listitem>
       <listitem>
         <para>exp</para>
       </listitem>
       <listitem>
         <para>int</para>
       </listitem>
       <listitem>
         <para>float</para>
       </listitem>
       <listitem>
         <para>log</para>
       </listitem>
       <listitem>
         <para>log10</para>
       </listitem>
       <listitem>
         <para>prime</para>
       </listitem>
       <listitem>
         <para>sin</para>
       </listitem>
       <listitem>
         <para>sinh</para>
       </listitem>
       <listitem>
         <para>sqrt</para>
       </listitem>
       <listitem>
         <para>tan</para>
       </listitem>
       <listitem>
         <para>tanh</para>
       </listitem>
    </itemizedlist>

    <para>To test the library, a small binary called prolingacalc is built when compiling.</para>

    <figure><title>Screenshot prolingacalc binary</title>
      <mediaobject>
        <imageobject><imagedata fileref="images/prolingacalc.png" format="PNG"/></imageobject>
        <textobject><phrase>Screenshot of the prolingacalc binary.</phrase></textobject>
      </mediaobject>
    </figure>

    <para>ProLinga-Calc has been built and tested on several popular GNU/Linux
    platforms as 
    RedHat Fedora, Mandriva Linux, 
    Debian, openSUSE Linux, Ubuntu and MS-Windows (Cygwin).
    Since all code is written
    in C++, it can be ported to all modern UNIX systems, Linux variants
    as well as Windows and Mac O/S platforms.</para>

    <para>Portions of code are lifted from the freeware application
    ccalc V1.01 programmed by <ulink type="http"
    url="http://www.garret.ru/~knizhnik/">Konstantin Knizhnik</ulink>.
    </para>

  </chapter>

  <chapter id="prolinga-calc-programming_notes">
    <title>ProLinga-Calc Programming Notes</title>

    <para>A very basic example program using ProLinga-Calc looks like this:</para>

<programlisting><![CDATA[
#include <stdio.h>
#include <prolinga/Calc.hpp>

int main()
{
	char *expression = "2+5";
	char *result;
	PlCalc calc;

	printf("Expression is %s\n", expression);

	result = calc.getCalc(expression);

	printf("Result is %s\n", result);

        return 0;
}
]]></programlisting>

    <para>This assigns <parameter>2 + 5</parameter> to 
    <parameter>expression</parameter>, calls the function <parameter>
    getCalc</parameter> of class PlCalc for the calculation of 
    <parameter>2 + 5</parameter> and assigns the
    outcome to <parameter>result</parameter>.</para>

    <para>To compile the program, use the following command:</para>
<programlisting>
g++ calc_test.cpp -o calc_test `pkg-config --cflags --libs prolinga-calc`
</programlisting>

    <note><para>You may need to set the environment variable PKG_CONFIG_PATH to 
    point to the directory where prolinga-calc.pc is located. By default this is
    directory <parameter>/usr/local/lib/pkgconfig</parameter> on Linux for
    example.
    </para></note>

    <para>You can also use a more traditional command as:</para>
<programlisting>
g++ calc_test.cpp -o calc_test -I/usr/local/include/ -L/usr/local/lib -lprolingacalc
</programlisting>


  </chapter>

  <chapter id="prolinga-calc-download">
    <title>Download ProLinga-Calc</title>

    <para>There are two types of product versions available for download:</para>

    <orderedlist>
      <listitem><para>Production Version</para></listitem>
      <listitem><para>Development Version</para></listitem>
    </orderedlist>

    <sect1 id="prolinga-calc-production_version">
      <title>Production Version</title>

      <para>The production version is an official product release. This is a
      stable completed version which should be used in production environments.
      Please visit the 
      <ulink type="http"
      url="http://download.prolinga.org">
      download page</ulink> for the latest details.</para>
    </sect1>

    <sect1 id="prolinga-calc-development_version">
      <title>Development Version</title>

      <para>The development version is a snapshot of the latest source files. Since
      it can contain bugs as part of "work in progress", this version should not
      be used in production environments. Only developers who want to help with
      further development of the ProLinga Projects should download this version. Please
      read the details at the <ulink type="http"
      url="prolinga-calc-subversion.html">Subversion</ulink>
      of how to obtain the latest development version.</para>

    </sect1>

  </chapter>

  <chapter id="prolinga-calc-build">
    <title>Build ProLinga-Calc</title>

    <sect1 id="prolinga-calc-prerequisites">
      <title>Prerequisites</title>

      <para>ProLinga-Calc &version; has been built and tested
      on Fedora, Mandriva Linux, 
      Debian, openSUSE Linux Ubuntu and MS-Windows (Cygwin). The product 
      should compile and run successfully on
      other Linux distributions as well as UNIX.
      GNU gcc/g++ >= 3.3 compilers/tools are required
      for a successful build.</para>

      <para>Required 3rd party package(s) for a successful build:</para>
      <itemizedlist>
        <listitem>
          <para>Math library libm.</para>
        </listitem>
      </itemizedlist>

      <para>Optional 3rd party package(s) for a successful build:</para>
      <itemizedlist>
        <listitem>
          <para>Command line processor
          <ulink type="http"
          url="http://xmlsoft.org/XSLT"><parameter>xsltproc</parameter></ulink>. This package
          is only required to re-generate the HTML pages after making changes to the documentation.</para>
        </listitem>
      </itemizedlist>

    </sect1>

    <sect1 id="prolinga-calc-build_instructions">
      <title>Build Instructions</title>
      <para/>

      <sect2 id="prolinga-calc-extracting_archive">
        <title>Extracting archive</title>

        <para>The product archive can be extracted to any desired directory
        using <parameter>unzip</parameter> (.zip file extension) or
        <parameter>gunzip</parameter> (.gz file extension) or
        <parameter>bunzip2</parameter> (.bz2 file extension) and 
        <parameter>tar</parameter>. After extracting, the following directories
        will be created:
        </para>

        <table frame="all" tocentry="1" >
        <title>Directory Structure.</title>
        <tgroup cols="2">
          <thead>
            <row>
              <entry>Directory</entry>
              <entry>Description</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry>&PRODUCT;-&version;</entry>
              <entry>Product version root directory.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/config</entry>
              <entry>Config build information.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/doc</entry>
              <entry>Documentation.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/src</entry>
              <entry>All source and internal header files.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/tests</entry>
              <entry>Self tests.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/prolinga</entry>
              <entry>External (API) header files.</entry>
            </row>
          </tbody>
        </tgroup>
        </table>

      </sect2>

      <sect2 id="prolinga-calc-compiling_linking">
        <title>Compiling and Linking</title>

        <para>To build the product go to the product root directory and run the 
        configure script. For default installation in /usr/local type:</para>

<programlisting>
./configure
</programlisting>

        <para>To install into another directory type:</para>

<programlisting>
./configure --prefix=<parameter>/any/dirname/</parameter>
</programlisting>

        <para>For all other configure options, type:</para>

<programlisting>
./configure --help
</programlisting>

        <para>After running the configure script, the product can be build with:</para>

<programlisting>
make
</programlisting>

        <para>To run the optional self-test type:</para>

<programlisting>
make check
</programlisting>

        <para>After compilation, the binaries, libraries and header files can be 
        installed with:</para>

<programlisting>
make install
</programlisting>

        <para>You may need root access for this last option.</para>

        <para>By default, HTML documentation pages are available in
        the doc/html directory. These pages are generated from 
        <ulink type="http"
        url="http://www.docbook.org">DocBook</ulink> XML file format
        files in /doc. To re-generate the HTML pages from these files type: </para>

<programlisting>
make html
</programlisting>

        <para>The command line XSLT processor <parameter>xsltproc</parameter> must be
        available from $PATH to be able to generate the HTML documentation.</para>

      </sect2>

      <sect2 id="prolinga-calc-dependencies">
        <title>Dependencies</title>

        <para>No dependencies on non-system libraries.</para>
      </sect2>

      <sect2 id="prolinga-calc-choose_build">
        <title>Choosing the right type of build</title>

        <para>The default configuration options provide libraries which 
        can be used both to develop/debug as to run the product. However better builds 
        are possible for a dedicated development or production environment.</para>

        <para>In <emphasis>production</emphasis> environments, builds are needed which contain minimal (debug) 
        overhead, so they are fast and small. To build such binaries/libraries, the 
        --enable-final options can be used. Example:</para>

<programlisting>
./configure --enable-final
</programlisting>

        <para>The enable-final flag is configured to be used with GCC environments only. 
        If access to more compilers become available over time, the enable-flag will be 
        ported to those compilers as well.</para>

        <para>In <emphasis>development</emphasis> environments, builds are needed producing warnings, enabling
        maximum debugging info etc. Several options are available here.</para>

      <itemizedlist>
         <listitem>
           <para>--enable-warnings : Set all compiler warning flags</para>
         </listitem>
         <listitem>
           <para>--enable-debug : Enable all debug messages</para>
         </listitem>
         <listitem>
           <para>--enable-gprof : Enables profiling with gprof (GCC only)</para>
         </listitem>
      </itemizedlist>


      </sect2>

    </sect1>

  </chapter>

  <chapter id="prolinga-calc-development">
    <title>Further development of ProLinga-Calc</title>

    <para>All ProLinga Projects are under constant active development. This includes
    issues related to fixing bugs, increasing performance etc, as well as expanding
    the various projects with new features. This chapter provides information of
    all these types of tasks as well as details of how to join the development team.</para>

    <sect1 id="prolinga-calc-todo">
      <title>To-do List</title>

      <para>This section contains a list of work that needs to be done on the product.
      A more detailed and up to date list is available on the
      <ulink type="http" url="http://bugzilla.prolinga.org">ProLinga Bugzilla Server</ulink>.
      </para>

      <itemizedlist>
         <listitem>
           <para>Self tests need to be further developed.</para>
         </listitem>
         <listitem>
           <para>Utilities.</para>
         </listitem>
         <listitem>
           <para>Code review and cleanup.</para>
         </listitem>
       </itemizedlist>

    </sect1>

    <sect1 id="prolinga-calc-subversion">
      <title>Subversion</title>

      <para>A Subversion tree containing the latest project sources is available at
      <ulink type="http" url="http://svn.prolinga.org">http://svn.prolinga.org</ulink>.
      For access please contact the <ulink type="http"
      url="http://lists.prolinga.org">ProLinga Team</ulink>.</para>

    </sect1>

    <sect1 id="prolinga-calc-bugzilla">
      <title>Bugzilla</title>

      <para>Bugzilla software development and bug tracking system to manage the ProLinga projects is available at
      <ulink type="http" url="http://bugzilla.prolinga.org">http://bugzilla.prolinga.org</ulink>.
      For access please contact the <ulink type="http"
      url="http://lists.prolinga.org">ProLinga Team</ulink>.</para>

    </sect1>

    <sect1 id="prolinga-calc-help_develop">
      <title>Help to Develop</title>

      <para>Are you ready to join the ProLinga development team? There are several ways you
      can help:</para>

      <itemizedlist>
         <listitem>
           <para>Use the product. Tell <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> what you think.</para>
         </listitem>
         <listitem>
           <para>Fixing bugs. Visit the development section on the
           <ulink type="http"
           url="http://www.prolinga.org">ProLinga Web Site</ulink>,
           choose a
           bug, fix it and send <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> the code changes.
           </para>
         </listitem>
         <listitem>
           <para>Enhancements. Have a look at the enhancement section of the
           <ulink type="http"
           url="prolinga-calc-development.html#prolinga-calc-todo">to-do list</ulink>
           and let <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> know which new feature you
           want to help to develop.</para>
         </listitem>
         <listitem>
           <para>Porting. To be successful it is essential that the ProLinga Projects
           are available on a wide range of platforms. We need help in porting and
           testing as well as providing binary releases for many different platforms.
           Let <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> know if and how you can help out.
           </para>
         </listitem>
         <listitem>
           <para>Real world examples. Are you using ProLinga products or do you know people
           who are happily using it. Please tell <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> the story and provide some screenshots.
           </para>
         </listitem>
      </itemizedlist>

    </sect1>

  </chapter>

  <part id="prolinga-calc-API">
    <title>ProLinga-Calc C++ API</title>

    <partintro>
      <para>This section contains the API reference for ProLinga-Calc.  All
      the public interfaces are documented here.</para>
    </partintro>

    <!-- The API documentation -->
    &prolinga-calc-API;

  </part>

  <part id="prolinga-calc-userguide">
    <title>ProLinga-Calc User Guide</title>

    <partintro>
      <para>This section contains the user guide for the ProLinga-Calculator.</para>
    </partintro>

    <!-- The User Guide documentation -->
    &prolinga-calc-userguide;

  </part>



  <!-- The document license -->
  &fdl;

</book>
