Author : Dua Guillaume
Date : 04-26-2020
Requirement : A first experience with CMake
As a modern C++ specialist, my job is to focus on software development, from a performance and quality perspective.
| #include <iterator> | |
| #include <istream> | |
| #include <string> | |
| #include <cassert> | |
| #include <cstddef> | |
| /** | |
| * Iterate over each part of a delimited input stream. | |
| * For example, to split a string into a vector: | |
| * |
| ('connect', 1, 0.0) | |
| ('send', 1, b'\x00\x00\x00\x85\xffSMBr\x00\x00\x00\x00\x18S\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe\x00\x00@\x00\x00b\x00\x02PC NETWORK PROGRAM 1.0\x00\x02LANMAN1.0\x00\x02Windows for Workgroups 3.1a\x00\x02LM1.2X002\x00\x02LANMAN2.1\x00\x02NT LM 0.12\x00', 9.812499774852768e-05) | |
| ('recv', 1, 0.011641267999948468) | |
| ('send', 1, b'\x00\x00\x00\x88\xffSMBs\x00\x00\x00\x00\x18\x07\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe\x00\x00@\x00\r\xff\x00\x88\x00\x04\x11\n\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xd4\x00\x00\x00K\x00\x00\x00\x00\x00\x00W\x00i\x00n\x00d\x00o\x00w\x00s\x00 \x002\x000\x000\x000\x00 \x002\x001\x009\x005\x00\x00\x00W\x00i\x00n\x00d\x00o\x00w\x00s\x00 \x002\x000\x000\x000\x00 \x005\x00.\x000\x00\x00\x00', 0.011713792999216821) | |
| ('recv', 1, 0.00983434200315969) |
| template<typename T> // описываем типы шаблонной функции | |
| void binary_form(T TYPE) { | |
| int z; | |
| for (char j = sizeof(T) * 8 - 1; j >= 0; j--) { | |
| z = ((T)1) << j; | |
| std::cout << ((TYPE & z) != 0) ? 1 : 0; // тернарный оператор ?:. Если условие до знака вопроса истинно, | |
| // то возвращает то, что между вопросом и двоеточием, если не истинно, то возвращает то, что после двоеточия и до конца операции | |
| } | |
| } |
| # compile | |
| $ g++ zlib-example.cpp -lz -o zlib-example | |
| # run | |
| $ ./zlib-example | |
| Uncompressed size is: 36 | |
| Uncompressed string is: Hello Hello Hello Hello Hello Hello! | |
| ---------- |
| // CaptureStackBackTrace | |
| // http://msdn.microsoft.com/en-us/library/windows/desktop/bb204633(v=vs.85).aspx | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> | |
| #include <stdio.h> | |
| ////////////////////////////////////////////////////////////// | |
| void capture() { | |
| const ULONG framesToSkip = 0; | |
| const ULONG framesToCapture = 64; |
| [DllImport("user32.dll")] | |
| internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); | |
| [StructLayout(LayoutKind.Sequential)] | |
| internal struct WindowCompositionAttributeData | |
| { | |
| public WindowCompositionAttribute Attribute; | |
| public IntPtr Data; | |
| public int SizeOfData; | |
| } |
| HMODULE hUser = GetModuleHandleA("user32.dll"); | |
| if (hUser) | |
| { | |
| pfnSetWindowCompositionAttribute setWindowCompositionAttribute = (pfnSetWindowCompositionAttribute)GetProcAddress(hUser, "SetWindowCompositionAttribute"); | |
| if (setWindowCompositionAttribute) | |
| { | |
| ACCENT_POLICY accent = { ACCENT_ENABLE_BLURBEHIND, 0, 0, 0 }; | |
| WINDOWCOMPOSITIONATTRIBDATA data; | |
| data.Attrib = WCA_ACCENT_POLICY; | |
| data.pvData = &accent; |