75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
// Demo for GDB pretty-printers verification.
|
|
// Build with -g, load into GDB, `source ../pip_pp.py`, `break main`, `run`, print globals.
|
|
#include "pibytearray.h"
|
|
#include "pichar.h"
|
|
#include "pimap.h"
|
|
#include "pinetworkaddress.h"
|
|
#include "pipair.h"
|
|
#include "piset.h"
|
|
#include "pistring.h"
|
|
#include "pivariant.h"
|
|
#include "pivector.h"
|
|
|
|
static PIString str_hello("hello");
|
|
static PIString str_cyr(PIString::fromUTF8("\xd0\xbc\xd0\xb8\xd1\x80")); // "мир"
|
|
static PIString str_empty;
|
|
static PIString str_esc;
|
|
static PIByteArray ba_hello(PIByteArray::fromHex("48656c6c6f")); // "Hello"
|
|
static PIVector<int> vec_int;
|
|
static PIVector<PIString> vec_str;
|
|
static PIVector<PIVector<int>> vec_vec;
|
|
static PIVector<int> vec_big;
|
|
static PIMap<PIString, int> map_str_int;
|
|
static PISet<int> set_int;
|
|
static PIStringList list_str;
|
|
static PIPair<PIString, int> pair_str_int;
|
|
static PIVariant var_int;
|
|
static PIVariant var_invalid;
|
|
static PIString * ptr_str = 0;
|
|
static PIString * ptr_null = 0;
|
|
static PIChar chr_a;
|
|
static PIChar chr_cyr;
|
|
static PINetworkAddress addr;
|
|
static PINetworkAddress addr_null;
|
|
|
|
namespace {
|
|
struct PPInit {
|
|
PPInit() {
|
|
vec_int << 1 << 2 << 3;
|
|
vec_str << "a" << "bb";
|
|
PIVector<int> inner;
|
|
inner << 10;
|
|
vec_vec << inner << vec_int;
|
|
for (int i = 0; i < 40; ++i) {
|
|
vec_big << i;
|
|
}
|
|
|
|
map_str_int["x"] = 1;
|
|
map_str_int["y"] = 2;
|
|
|
|
set_int << 5 << 3;
|
|
|
|
list_str << "one" << "two";
|
|
|
|
pair_str_int = PIPair<PIString, int>("k", 7);
|
|
|
|
var_int = PIVariant(42);
|
|
var_invalid = PIVariant();
|
|
|
|
ptr_str = &str_hello;
|
|
|
|
chr_a = PIChar('a');
|
|
chr_cyr = PIChar((char16_t)0x043C);
|
|
|
|
addr = PINetworkAddress(PIString("192.168.1.10"), 8080);
|
|
|
|
str_esc = "a\"b\\c\nd\te";
|
|
}
|
|
};
|
|
static PPInit pp_init;
|
|
} // namespace
|
|
|
|
int main() {
|
|
return 0;
|
|
}
|