FLTK logo

Article #509: SPTK 3.0

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Articles | Show Comments | Submit Comment ]

Article #509: SPTK 3.0

Created at 06:40 Sep 25, 2005 by alexey.parshin

The massive SPTK CVS update is just completed. The building system is replaced by autoconf/automake based. So, the following changes are made:

  • Include files now reside in sptk3/ (not in sptk/). That should allow to install both SPTK versions, 2.x and 3.x, simultaneously.
  • All the SPTK libraries now have the major version number 3 (not 2) : libsptk3.so, libspdb3.so, etc..
  • Configure script (.configure) now includes --enable-examples switch to enable building examples. However, even if you pass the switch, examples aren't automatically built - you have to go to examples/ directory, and run make separately.

In the source code, there are 3 sets of changes. If used correctly, these changes allow you to simplify your code and make it work faster.

  • In the XML module, the method CXmlDoc::createElement() and similar are no longer public. Instead, <sptk3/xml/CXmlNode.h> gives you several simple classes that allow to create XML object.

    Old style code <br />

        CXmlDoc *doc = parentNode->document();
        CXmlNode *node = doc->createElement("book");
        parentNode->add(node); 

    New style code

        CXmlNode *node = new CXmlElement(parentNode,"book"); 
    

    While the new form is obviously shorter, it also makes sure that the node is attached to the parentNode. Don't try to use NULL for the parentNode - it would cause GPF instantly :)
  • The CXmlNode methods getAttribute() and setAttribute() got a new optional parameter, const char *defaultValue. If defined, it makes getAttribute() method return the value to if attribute is missing. For the setAttribute(), the defaultValue makes CXmlNode to remove the attribute. This way, if a lot of the attributes in XML file have the default values, the size of the file is drastically decreased.
  • The CFieldList class got a support for the streamed output for most used SPTK classes. The following example illustrates it:<br />
          int id;
          std::string name;
          CDateTime birthDate;
          CQuery query(db,"select id,name,dob from people");
          query.open();
          while (!query.eof()) {
             query.fields() >> id >> name >> birthDate;
             query.next();
          }
          query.close();
    

  • The CParams class got a support for the streamed input for most used SPTK classes. The following example illustrates it:<br />
          int id = 12345;
          std::string name = "Alex";
          CDateTime birthDate;
          CQuery query(db,"select id,name,dob from people where id > :id and name = :name");
          query.params() << id << name;
          query.open();
          ...
    

These changes would be available in the next version, SPTK 3.1, after about a week of testing. Feel free to drop me a line.

Download | Home Page | Listing ]


Comments

Submit Comment ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.