Monday, November 26, 2012

HRESULT lookup tool

There is a useful tool HRPlus for those who works with Microsoft COM. This tool can lookup HRESULTs. You can lookup different codes in binaries, also you can create a new own codes:

Saturday, November 24, 2012

How to: djvu and kindle

There are a lot of ways to perform DJVU to PDF converting. I have investigated a lot of them(online tools, pdf-printers and standalone tools) - and all of them were awful(bad speed, bad quality, shareware, etc.). But recently i've found a nice tool, which performs necessary converting better then others:

1. Go to djvu.sourceforge.net
2. Download binary package(in example my target platform is Windows)
3. Use ddjvu.exe tool, for convertation f.e.:
    C:\Program Files (x86)\DjVuZone\DjVuLibre>ddjvu -format=pdf book.djvu book.pdf

Sunday, July 29, 2012

Yoda Conditions

Yoda-conditions
Using if (constant == variable) instead of if (variable == constant), like if (4 == foo). Because it's like saying "if blue is the sky" or "if tall is the man".

Monday, July 16, 2012

IID_PPV_ARGS

Useful macro, instead this:
hr = CoCreateInstance(
    __uuidof(FileOpenDialog), NULL, CLSCTX_ALL,
    __uuidof(IFileDialogCustomize), reinterpret_cast<void**>(&pFileOpen));

we can write:
hr = CoCreateInstance(
    __uuidof(FileOpenDialog), NULL, CLSCTX_ALL,
    IID_PPV_ARGS(&pFileOpen));

Thursday, July 12, 2012

std::vector of pointers vs vector of elements/values

Some info about pointer vs value.

Vector of elements:

+Do not need to free/allocate memory for elements
+Keep it simple
+All elements memory allocated as one memory block - it increases cache hit and reduces memory fragmentation
+STL algorithms friendly
+Do not uses additional memory for pointer

Vector of pointers:
+Polymorphism
+If we don't know how much of memory we will need
+If we will need a lot of large objects
+Small pointers size useful for pointer to elements swaps

Tuesday, February 28, 2012

class and struct in C++

Differences between keywords class and struct in C++:
- In absence of an access-specifier for a base class, public is assumed when the derived class is declared struct and private is assumed when the class is declared class;
- Member of a class defined with the keyword class are private by default. Members of a class defined with the keywords struct or union are public by default;
- Keyword class can be used to declare a template parameter, while struct cannot;
- Keyword struct is compatible with C language, while class is not
.