Generators in C++ revisited.

Previous version of generators has a design problem – it required some special stop value. That is the same kind of problem as with iterators in C++ – they require special end() value. But in some cases it is not even possible to choose such a value. So is this new version: // generator/continuation for…

Generators in C++

As we know iterators in C++ is a good but not perfect abstraction. Concept of foreach() (D, Python, Ruby, etc.) appears as more generic solution. At least foreach() does not require artificial iterator::end() to be defined for the collection. Abstraction foreach() can be imagined as some function/object that is returning next value of collection/sequence each…

JavaScript. Private members (instance variables).

As you know JavaScript has no concept of private members in objects. Objects there are “racks of properties” that anyone can change. Here is a simple way of making “objects” in JS that have private instance variables. Such variables can be changed only by [public] methods you provide. Consider following code: function CreateMyObject() { var…

Sciter. Working with persistent data (database)

Here is an example of minimalistic application working with DB (persistent data) in Sciter. This sample is using three files: simple-db-form.htm – main file of our application; db.tis – open or create database; form.tis – behavior that handles showing/saving data from list of input elements on the form. db.tis – open or create database This…

XML/HTML tokenizer (or pull parser?)

Here is source code of my XML/HTML tokenizer: xh_scanner_demo.zip See my article on CodeProject: HTML/XML scanner/tokenizer Does not allocate any memory while parsing, extremely fast and compact.