<commit_before>﻿
#include <iostream>
#include <fbxsdk.h>
#include "common.h"
#include <set>
#include <iomanip>
#include "Collector.h"
#include <algorithm>

using namespace std;

bool sort_by_id(FbxObject* a, FbxObject* b)
{
    if (a == NULL)
    {
        cout << "sort_by_id a is NULL" << endl;
    }
    if (b == NULL)
    {
        cout << "sort_by_id b is NULL" << endl;
    }

    if (a == NULL && b == NULL) return false;
    if (a == NULL) return false;
    if (b == NULL) return true;

    return (a->GetUniqueID() < b->GetUniqueID());
}

void PrintObjectGraph(FbxObject* obj)
{
    Collector c;

    c.Visit(obj);

    cout << endl;

    vector<FbxObject*>& objs = c.Objects;
    sort(objs.begin(), objs.end(), sort_by_id);

    vector<FbxObject*>::iterator it;
    for (it = objs.begin(); it != objs.end(); ++it)
    {
        PrintObject(*it);
    }
}

void PrintObjectID(FbxObject* obj)
{
    if (obj == NULL)
        cout << "<<null>>";
    else
        cout <<
            "$" << obj->GetUniqueID() << ", " <<
            obj->GetRuntimeClassId().GetName() << ", " <<
            quote(obj->GetName());
}

std::string id(FbxObject* obj)
{
    if (obj == NULL) return "<<null>>";

    std::stringstream ss;
    ss <<   "$" << obj->GetUniqueID() << ", " <<
            obj->GetRuntimeClassId().GetName() << ", " <<
            quote(obj->GetName());

    return ss.str();
}

void PrintPropertyID(FbxProperty* prop)
{
    if (prop == NULL)
        cout << "<<null>>";
    else if (!prop->IsValid())
    {
        cout << "<<invalid>>";
    }
    else
    {
        FbxObject* pobj = prop->GetFbxObject();
        PrintObjectID(pobj);
        cout << " -> " << quote(prop->GetName()) << " : " << prop->GetPropertyDataType();
    }
}

void PrintObject(FbxObject* obj)
{
    cout << "$"; PrintObjectID(obj); cout << endl;  // extra $ for easy text search
    cout << "    Name = " << quote(obj->GetName()) << endl;
    cout << "    ClassId = " << obj->GetRuntimeClassId().GetName() << endl;
    cout << "    UniqueId = " << obj->GetUniqueID() << endl;
    cout << "    GetScene() = "; PrintObjectID(obj->GetScene()); cout << endl;
    cout << "    GetDocument() = "; PrintObjectID(obj->GetDocument()); cout << endl;
    cout << "    GetRootDocument() = "; PrintObjectID(obj->GetRootDocument()); cout << endl;
    cout << "    SrcObjectCount = " << obj->GetSrcObjectCount() << endl;
    int i;
    for (i = 0; i < obj->GetSrcObjectCount(); i++)
    {
        FbxObject* srcObj = obj->GetSrcObject(i);
        cout << "        #" << i << " ";
        PrintObjectID(srcObj);
        cout << endl;
    }
    cout << "    DstObjectCount = " << obj->GetDstObjectCount() << endl;
    for (i = 0; i < obj->GetDstObjectCount(); i++)
    {
        FbxObject* dstObj = obj->GetDstObject(i);
        cout << "        #" << i << " ";
        PrintObjectID(dstObj);
        cout << endl;
    }

    FbxProperty prop = obj->GetFirstProperty();
    int n = 0;
    while (prop.IsValid())
    {
        n++;<commit_msg>Print out an object's name, namespace, etc.<commit_after>﻿
#include <iostream>
#include <fbxsdk.h>
#include "common.h"
#include <set>
#include <iomanip>
#include "Collector.h"
#include <algorithm>

using namespace std;

bool sort_by_id(FbxObject* a, FbxObject* b)
{
    if (a == NULL)
    {
        cout << "sort_by_id a is NULL" << endl;
    }
    if (b == NULL)
    {
        cout << "sort_by_id b is NULL" << endl;
    }

    if (a == NULL && b == NULL) return false;
    if (a == NULL) return false;
    if (b == NULL) return true;

    return (a->GetUniqueID() < b->GetUniqueID());
}

void PrintObjectGraph(FbxObject* obj)
{
    Collector c;

    c.Visit(obj);

    cout << endl;

    vector<FbxObject*>& objs = c.Objects;
    sort(objs.begin(), objs.end(), sort_by_id);

    vector<FbxObject*>::iterator it;
    for (it = objs.begin(); it != objs.end(); ++it)
    {
        PrintObject(*it);
    }
}

void PrintObjectID(FbxObject* obj)
{
    if (obj == NULL)
        cout << "<<null>>";
    else
        cout <<
            "$" << obj->GetUniqueID() << ", " <<
            obj->GetRuntimeClassId().GetName() << ", " <<
            quote(obj->GetName());
}

std::string id(FbxObject* obj)
{
    if (obj == NULL) return "<<null>>";

    std::stringstream ss;
    ss <<   "$" << obj->GetUniqueID() << ", " <<
            obj->GetRuntimeClassId().GetName() << ", " <<
            quote(obj->GetName());

    return ss.str();
}

void PrintPropertyID(FbxProperty* prop)
{
    if (prop == NULL)
        cout << "<<null>>";
    else if (!prop->IsValid())
    {
        cout << "<<invalid>>";
    }
    else
    {
        FbxObject* pobj = prop->GetFbxObject();
        PrintObjectID(pobj);
        cout << " -> " << quote(prop->GetName()) << " : " << prop->GetPropertyDataType();
    }
}

void PrintObject(FbxObject* obj)
{
    cout << "$"; PrintObjectID(obj); cout << endl;  // extra $ for easy text search
    cout << "    Name = " << quote(obj->GetName()) << endl;
    cout << "      GetNameWithoutNameSpacePrefix = " << quote(obj->GetNameWithoutNameSpacePrefix()) << endl;
    cout << "      GetNameWithNameSpacePrefix = " << quote(obj->GetNameWithNameSpacePrefix()) << endl;
    cout << "      GetInitialName = " << quote(obj->GetInitialName()) << endl;
    cout << "      GetNameSpaceOnly = " << quote(obj->GetNameSpaceOnly()) << endl;
    FbxArray<FbxString*> namespaces = obj->GetNameSpaceArray('n');
    cout << "      GetNameSpaceArray (" << namespaces.GetCount() << ")" << endl;
    int i;
    for (i = 0; i < namespaces.GetCount(); i++)
    {
        FbxString* ns = namespaces.GetAt(i);
        cout << "        # " << i << " " << quote(*ns) << endl;
    }
    cout << "      GetNameOnly = " << quote(obj->GetNameOnly()) << endl;
    cout << "      GetNameSpacePrefix = " << quote(obj->GetNameSpacePrefix()) << endl;
    cout << "    ClassId = " << obj->GetRuntimeClassId().GetName() << endl;
    cout << "    UniqueId = " << obj->GetUniqueID() << endl;
    cout << "    GetScene() = "; PrintObjectID(obj->GetScene()); cout << endl;
    cout << "    GetDocument() = "; PrintObjectID(obj->GetDocument()); cout << endl;
    cout << "    GetRootDocument() = "; PrintObjectID(obj->GetRootDocument()); cout << endl;
    cout << "    SrcObjectCount = " << obj->GetSrcObjectCount() << endl;
    for (i = 0; i < obj->GetSrcObjectCount(); i++)
    {
        FbxObject* srcObj = obj->GetSrcObject(i);
        cout << "        #" << i << " ";
        PrintObjectID(srcObj);
        cout << endl;
    }
    cout << "    DstObjectCount = " << obj->GetDstObjectCount() << endl;
    for (i = 0; i < obj->GetDstObjectCount(); i++)
    {
        FbxObject* dstObj = obj->GetDstObject(i);
        cout << "        #" << i << " ";
        PrintObjectID(dstObj);
        cout << endl;
    }

    FbxProperty prop = obj->GetFirstProperty();
    int n = 0;
    while (prop.IsValid())
    {
        n++;
{'fraction_non_alphanumeric': 0.19518910302854658, 'fraction_numerical': 0.0010143457469931894, 'mean_word_length': 2.4355400696864113, 'pattern_counts': {'":': 0, '<': 315, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5965134', 'n_tokens_mistral': 2380, 'n_tokens_neox': 2322, 'n_words': 489}