MCPcopy Create free account
hub / github.com/baldurk/renderdoc / ParseFormatString

Method ParseFormatString

qrenderdoc/Code/BufferFormatter.cpp:540–2428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

538}
539
540ParsedFormat BufferFormatter::ParseFormatString(const QString &formatString, uint64_t maxLen,
541 bool cbuffer)
542{
543 ParsedFormat ret;
544
545 StructFormatData root;
546 StructFormatData *cur = &root;
547
548 QMap<QString, StructFormatData> structelems;
549 QString lastStruct;
550
551 // regex doesn't account for trailing or preceeding whitespace, or comments
552
553 QRegularExpression regExpr(
554 lit("^" // start of the line
555 "(?<major>row_major\\s+|column_major\\s+)?" // matrix majorness
556 "(?<sign>unsigned\\s+|signed\\s+)?" // allow 'signed int' or 'unsigned char'
557 "(?<rgb>rgb\\s+)?" // rgb element colourising
558 "(?<type>" // group the options for the type
559 "uintten|unormten" // R10G10B10A2 types
560 "|floateleven" // R11G11B10 special type
561 "|unormh|unormb" // UNORM 16-bit and 8-bit types
562 "|snormh|snormb" // SNORM 16-bit and 8-bit types
563 "|bool" // bool is stored as 4-byte int
564 "|byte|short|int|long|char" // signed ints
565 "|ubyte|ushort|uint|ulong" // unsigned ints
566 "|xbyte|xshort|xint|xlong" // hex ints
567 "|half|float|double" // float types
568 "|vec|uvec|ivec|dvec" // OpenGL vector types
569 "|mat|umat|imat|dmat" // OpenGL matrix types
570 "|int8_t|uint8_t" // C-style sized 8-bit types
571 "|int16_t|uint16_t" // C-style sized 16-bit types
572 "|int32_t|uint32_t" // C-style sized 32-bit types
573 "|int64_t|uint64_t" // C-style sized 64-bit types
574 "|float16_t|float32_t|float64_t" // C-style sized float types
575 ")" // end of the type group
576 "(?<vec>[1-9])?" // might be a vector
577 "(?<mat>x[1-9])?" // or a matrix
578 "(" // pointer or space
579 "(?<ptr>\\s*\\*\\s*)|" // pointer asterisk
580 "\\s+|" // or just some whitespace
581 "$" // or the end, if it's nameless
582 ")" // end pointer or space
583 "(?<name>[A-Za-z@_][A-Za-z0-9@_]*)?" // get identifier name
584 "(?<array>\\s*\\[[0-9]*\\])?" // optional array dimension
585 "(\\s*:\\s*" // optional specifier after :
586 "(" // bitfield or semantic
587 "(?<bitfield>[1-9][0-9]*)|" // bitfield packing
588 "(?<semantic>[A-Za-z_][A-Za-z0-9_]*)" // semantic to ignore
589 ")" // end bitfield or semantic
590 ")?"
591 "$"));
592
593 bool success = true;
594
595 // remove any dos newlines
596 QString text = formatString;
597 text.replace(lit("\r\n"), lit("\n"));

Callers

nothing calls this directly

Calls 15

IsD3DFunction · 0.85
QLatin1CharClass · 0.85
MatchBaseTypeDeclarationFunction · 0.85
VarTypeCompTypeFunction · 0.85
VarTypeByteSizeFunction · 0.85
ToStrFunction · 0.85
trimmedMethod · 0.80
toLowerMethod · 0.80
trFunction · 0.70
AlignUpFunction · 0.70
QStringFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected