Kernel word recovery crack, Mobile themes website for samsung wave 525, Dekha ek khwab sony tv title song, Song zombies on your lawn, Bloody mary nerve endings mp3, Digittrade tv jukebox, Padosan songs mp3, Gold cup series 70 manual, Nieuwste versie van mozilla firefox en, Cant install spotify on mac, Web brute force password cracker, Belkin g peek driver windows 7

Archive for the ‘Qt’ category


June 7th, 2012

After considering several variant classes for my ongoing project, I decided to roll my own.

Compared to other variant types, it implements:

– Registration of named structured types.
– Registration of type conversions. A conversion doesn’t have to always succeed. For instance a MIDI Channel message may be converted into a MIDI Controller message, but may also be an incompatible MIDI note message.
– Binary (de-)serialization to QDataStream.
– Textual (de-)serialization to QTextStream. There is an unambiguous mode useful for debugging and datatransfer (altough QDataStream is likely to be more appropriate in this case) and a “human” mode useful for displaying values, human input and scripting.

A quick example of basic functionality.

#include <vmvalue.h>
#include <vmtypemanager.h>
#include <QStringList>
int main() {
    VMValue a = 3;
    Q_ASSERT(a.intValue() == 3);
    Q_ASSERT(a.type() == VMValue::IntType);
    VMValue b = "Hello Mars !";
    Q_ASSERT(b.stringValue() == "Hello Mars !");
    Q_ASSERT(b.type() == VMValue::StringType);
    VMValue x;
    x = QStringList({"welcome", "back"});
    Q_ASSERT(x.type() == VMValue::StringListType);
    VMValue rect = VMValue::byName("Rect");
    Q_ASSERT(rect.typeName() == "Rect");
    rect.setAttribute("x", 200);
    Q_ASSERT(rect.attribute("x").intValue() == 200);

An example of a custom datatypes and a casting function:

VMValue castChannelMessageToControllerMessage(const VMValue& source) {
    if (source.attribute("status") != MIDI_CTL_STATUS)
        return VMValue::Invalid;
    VMValue v = VMValue::byName("ControllerMessage");
    v.setAttribute("channel", source.attribute("channel"));
    v.setAttribute("ctl", source.attribute("data0"));
    v.setAttribute("value", source.attribute("data1"));
    return v;
int main() {
    VMTypeDef* channelMsgDef = new VMTypeDef;
    channelMsgDef->addAttribute("channel", VMValue::IntType, 0);
    channelMsgDef->addAttribute("status", VMValue::IntType, 0);
    channelMsgDef->addAttribute("data0", VMValue::IntType, 0);
    channelMsgDef->addAttribute("data1", VMValue::IntType, 0);
    VMTypeDef* ctlMsgDef = new VMTypeDef;
    ctlMsgDef->addAttribute("channel", VMValue::IntType, 0);
    ctlMsgDef->addAttribute("ctl", VMValue::IntType, 0);
    ctlMsgDef->addAttribute("value", VMValue::IntType, 0);
    vmTypeManager()->registerType("ChannelMessage", channelMsgDef);
    vmTypeManager()->registerType("ControllerMessage", ctlMsgDef);
    vmTypeManager()->registerCastFunction("ChannelMessage", "ControllerMessage",
    VMValue channelMsg = VMValue::byName("ChannelMessage");
    channelMsg.setAttribute("status", MIDI_CTL_STATUS);
    channelMsg.setAttribute("data0", MIDI_DAMPER_CTL);
    channelMsg.setAttribute("data1", 127);
    VMValue ctlMsg = channelMsg.castTo("ControllerMessage");
    Q_ASSERT(ctlMsg.attribute("ctl").intValue() == MIDI_DAMPER_CTL);
    return 0;

Human-readable serialization to QTextStream using VMValueDumper and VMValueParser example:

    VMValueDumper dumper;
    Q_ASSERT(dumper.dump(5) == "5");
    Q_ASSERT(dumper.dump("hello") == "hello");
    Q_ASSERT(dumper.dump(IntList({1, 2, 3})), "I[1,2,3]");
    // ControllerMessage from previous example
    Q_ASSERT(dumper.dump(ctlMsg) == "@ControllerMessage{channel:0,ctl:7,value:127}");
    VMValueParser parser;
    VMValue x = parser.parse("\"hello world\"");
    Q_ASSERT(x.stringValue(), "hello world");

The missing part is currently the ability to share a value between VMValues to optimize data transfer between Units in the a graph, especially for streaming nodes (audio, video).

There isn’t much documentation for the code, except the comments inside the source and some design files, but there are unit tests that show the intended use of these classes.

As the API isn’t fully stabilized yet, the source code is available on request.

Test Monkey

February 28th, 2012

To test my ongoing projects, or rather to do some test based development, I wrote some simple C++ classes and macros that emulate the Qt testing framework with some differences.

– Testing functions don’t need to be in a Q_OBJECT but are normal C-style functions.
– More information about the location of a failed test, debug/warning/error messages and segmentation faults.
– A QLOGCOMPARE macro that displays a diff of two lists of strings that can be populated by a MonkeyLogger stream.

To illustrate how this works, let me show you a short example.

#include <QCoreApplication>
#include <QStringList>
#include "testmonkey.h"
#include "monkeylogger.h"
void raiseWarning() {
    qWarning("Warning: do not call me !");
void raiseFault() {
    struct Foo { int bar; };
    Foo* foo = 0;
    int a = 5;
    int b = 4;
    QVERIFY(a < 0);
    QCOMPARE(a, b);
    MonkeyLogger result;
    MonkeyLogger expected;
    expected() << "line1";
    expected() << "line2";
    expected() << "line3";
    result() << "line1";
    result() << "bogus";
    result() << "line3";
    QLOGCOMPARE(result.entries(), expected.entries());
//  raiseFault();
    QVERIFY(1 > 0);
    int a = 0;
    int b = 1;
    QVERIFY(a < b);
int main(int argc, char *argv[]) {
    QCoreApplication(argc, argv);
    return 0;

Running this examples yields the following output:

     Test failed at main.cpp:24:
        Expression: a < 0
     Comparison failed at main.cpp:25
        Expression: a
          Expected: "4"
               Got: 5
    Log comparison failed at main.cpp:36
  RESULT                                       EXPECTED                                    
  line1                                        line1                                       
* bogus                                        line2                                       
  line3                                        line3                                       
     -> after main.cpp:36 in test myTest (outside a test macro):
        WARNING: main.cpp:11, void raiseWarning()
            Warning: do not call me !
FAIL myTest (1/4)
OK   allOk
1/2 TESTS SUCCEEDED. (3/6 tests)

If raiseFault() line in the myTest method were to be uncommented, the program would stop with the following message:

     -> after main.cpp:36 in test myTest (outside a test macro):
        SEGFAULT caught

Some random notes:

– In this example the logging functionality is kind of stupid. In reality it is useful to log signals. A monitor object is create that connects to the signals that are to be monitored and logs a textual representation of the signal to a MonkeyLogger. Another MonkeyLogger object is created in the test function, and logs stores the expected signal representations.
– When debug/warning message and segfaults are caught, the last known location in a test function is displayed. This is the location of the last test macro (QCOMPARE, QVERIFY, QLOGCOMPARE) that was called. If the message was not the result of a call from one of these macros, the displayed message is “after file.cpp:line in test Test (outside a test macro)”, which means the error occurred anywhere between that location and the next test macro or the end of the test function.
– The MONKEY_TEST macro registers a function with the TestMonkey framework using a static TestMonkey object. While this is quick and dirty, it also means that registration order is undetermined if you use multiple object files containing testing functions. This can be a source of errors if they use other global objects, so remember to have everything initialized before calling TestMonkey::run().
– As my current projects use C++11 and this testing framework is mostly for myself (but feel free to use), TestMonkey requires C++11.
– The Qt testing macros that handle data sets are not implemented.

Attached Files: