MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / PrintCppStruct

Function PrintCppStruct

Tools/etw_list/etw_list.cpp:588–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588void PrintCppStruct(std::vector<EventProperty> const& members, std::wstring const& name)
589{
590 auto memberCount = members.size();
591 if (memberCount == 0) {
592 return;
593 }
594
595 // First print any member struct dependencies
596 {
597 size_t memberIndex = 1;
598 for (auto const& member : members) {
599 if (member.Flags & PropertyStruct) {
600 PrintCppStruct(member.members_, GetMemberStructName(name, memberIndex));
601 memberIndex += 1;
602 }
603 }
604 }
605
606 // Break the struct up into parts at any variable-sized member
607 std::vector<std::pair<size_t, bool> > parts;
608 {
609 bool hasPointerMember = false;
610 for (size_t i = 0; ; ++i) {
611 auto const& member = members[i];
612 if (HasPointer(member)) {
613 hasPointerMember = true;
614 }
615 if (i == memberCount - 1) break;
616 // If is variable length ...
617 if (((member.Flags & (PropertyParamLength | PropertyParamCount)) != 0) ||
618 ((member.Flags & (PropertyWBEMXmlFragment | PropertyHasCustomSchema | PropertyParamFixedLength | PropertyParamFixedCount)) == 0 &&
619 (member.nonStructType.InType == TDH_INTYPE_UNICODESTRING ||
620 member.nonStructType.InType == TDH_INTYPE_ANSISTRING ||
621 member.nonStructType.InType == TDH_INTYPE_SID))) {
622 parts.emplace_back(i + 1, hasPointerMember);
623 hasPointerMember = false;
624 }
625 }
626 parts.emplace_back(memberCount, hasPointerMember);
627 }
628
629 for (size_t memberIndex = 0, structMemberIndex = 1, partIndex = 0, partCount = parts.size(); partIndex < partCount; ++partIndex) {
630 auto const& part = parts[partIndex];
631 auto partEnd = part.first;
632 auto partHasPointerMembers = part.second;
633
634 // Start the struct for this part
635 if (partHasPointerMembers) {
636 printf("template<typename PointerT>\n");
637 }
638 printf("struct %ls_Struct", name.c_str());
639 if (partCount > 1) {
640 printf("_Part%zu", partIndex + 1);
641 }
642 printf(" {\n");
643
644 // Add the members for this part
645 for ( ; memberIndex < partEnd; ++memberIndex) {

Callers 1

wmainFunction · 0.85

Calls 4

GetMemberStructNameFunction · 0.85
HasPointerFunction · 0.85
CppConditionFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected