How can I deterministically sort raw C++ code

77 Views Asked by At

I have few hundred thousand translation units of raw, but UE decorated C++ like code:

#include "Somefile.h"

class Whatever;

UCLASS(Blueprintable)
class GAME_API USubsystem : public UEngineSubsystem {
    GENERATED_BODY()
public:
// etc
private:
    UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
    UObject* Data;
}

and the likes. For very specific review/overview purposes only, I need to process the code and sort it in a deterministic ABC order:

  • all includes are in top, sorted
  • all forward type declarations follow includes, sorted as well
  • classes, as whole scoped objects, sorted alphabetically as well, by class name.
  • within classes, property/field declarations sorted by name
  • functions follow them
  • preservation of access modifiers is not required
  • only header files needs to be processed

How can I possibly achieve it, en masse?

0

There are 0 best solutions below