Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fuck Standard C++ Containers

Name: Anonymous 2012-05-23 0:49

Do it the old fashioned way, less bloat, easier to understand.

http://codepad.org/ZVqiyIfV

Name: Anonymous 2012-05-23 3:18

>>3
It's also less flexible for arbitrary data types, not easily composed and generates insane code.
There's these things called inheritance and lambda expressions in C++11. It's better than shitting your binaries up with bloated abstractions and shitty object-models.


struct log_sink : list_node_t
{
    log_handler handler;
    unsigned int min_level;
    unsigned int max_level;
    char category[196];
           
    log_sink(char const* n, log_handler h, unsigned int min, unsigned int max)
    : handler(h),
    min_level(min),
    max_level(max) {
        ::up::list_init(this);
        strncpy(category, n, sizeof(category) - 1);
        category[sizeof(category) - 1] = '\0';
    }
};

// ...

::up::list_foreach<log_sink>(&context->sinks_sentinel, [&](log_sink* sink) {
    if ( (sink->category[0] == '\0' || !strcmp(sink->category, record.category))
        && (sink->min_level <= record.level) && (record.level <= sink->max_level)
    ) {
        sink->handler(&record);
    }
});
     
::up::list_clear<log_sink>(&sinks_sentinel, [](log_sink* sink) { ::up::destroy_free(sink); });

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List