<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_UNOIDL_SOURCE_SOURCEPROVIDER_SCANNER_HXX
#define INCLUDED_UNOIDL_SOURCE_SOURCEPROVIDER_SCANNER_HXX

#include "sal/config.h"

#include <cassert>
#include <map>
#include <vector>

#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "salhelper/simplereferenceobject.hxx"
#include "unoidl/unoidl.hxx"

#include "sourceprovider-parser-requires.hxx"
#include "sourceprovider-parser.hxx"

namespace unoidl { namespace detail {

class SourceProviderEntityPad: public salhelper::SimpleReferenceObject {
public:
    bool isPublished() const { return published_; }

protected:
    explicit SourceProviderEntityPad(bool published): published_(published) {}

    virtual ~SourceProviderEntityPad() {}

private:
    bool const published_;
};

class SourceProviderEnumTypeEntityPad: public SourceProviderEntityPad {
public:
    explicit SourceProviderEnumTypeEntityPad(bool published):
        SourceProviderEntityPad(published)
    {}

    std::vector<unoidl::EnumTypeEntity::Member> members;

private:
    virtual ~SourceProviderEnumTypeEntityPad() throw () {}
};

class SourceProviderPlainStructTypeEntityPad: public SourceProviderEntityPad {
public:
    SourceProviderPlainStructTypeEntityPad(
        bool published, OUString theBaseName,
        rtl::Reference<unoidl::PlainStructTypeEntity> const & theBaseEntity):
        SourceProviderEntityPad(published), baseName(theBaseName),
        baseEntity(theBaseEntity)
    { assert(theBaseName.isEmpty() != theBaseEntity.is()); }

    OUString const baseName;
    rtl::Reference<unoidl::PlainStructTypeEntity> const baseEntity;
    std::vector<unoidl::PlainStructTypeEntity::Member> members;

private:
    virtual ~SourceProviderPlainStructTypeEntityPad() throw () {}
};

class SourceProviderPolymorphicStructTypeTemplateEntityPad:
    public SourceProviderEntityPad
{
public:
    SourceProviderPolymorphicStructTypeTemplateEntityPad(bool published):
        SourceProviderEntityPad(published)
    {}

    std::vector<OUString> typeParameters;
    std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member> members;

private:
    virtual ~SourceProviderPolymorphicStructTypeTemplateEntityPad() throw () {}
};

class SourceProviderExceptionTypeEntityPad: public SourceProviderEntityPad {
public:
    SourceProviderExceptionTypeEntityPad(
        bool published, OUString theBaseName,
        rtl::Reference<unoidl::ExceptionTypeEntity> const & theBaseEntity):
        SourceProviderEntityPad(published), baseName(theBaseName),
        baseEntity(theBaseEntity)
    { assert(theBaseName.isEmpty() != theBaseEntity.is()); }

    OUString const baseName;
    rtl::Reference<unoidl::ExceptionTypeEntity> const baseEntity;
    std::vector<unoidl::ExceptionTypeEntity::Member> members;

private:
    virtual ~SourceProviderExceptionTypeEntityPad() throw () {}
};

class SourceProviderInterfaceTypeEntityPad: public SourceProviderEntityPad {
public:
    struct Base {
        Base(
            OUString const & theName,
            rtl::Reference<unoidl::InterfaceTypeEntity> const & theEntity,
            std::vector<OUString> const & theAnnotations):
            name(theName), entity(theEntity), annotations(theAnnotations)
        {}

        OUString name;
        rtl::Reference<unoidl::InterfaceTypeEntity> entity;
        std::vector<OUString> annotations;
    };

    SourceProviderInterfaceTypeEntityPad(
        bool published, OUString singleBaseName,
        rtl::Reference<unoidl::InterfaceTypeEntity> const & singleBaseEntity):
        SourceProviderEntityPad(published),
        singleBase(!singleBaseName.isEmpty())
    {
        assert(singleBaseName.isEmpty() != singleBaseEntity.is());
        if (singleBase) {
            mandatoryBases.push_back(
                Base(
                    singleBaseName, singleBaseEntity, std::vector<OUString>()));
        }
    }

    bool singleBase;
    std::vector<Base> mandatoryBases;
    std::vector<Base> optionalBases;
    std::vector<unoidl::InterfaceTypeEntity::Attribute> attributes;
    std::vector<unoidl::InterfaceTypeEntity::Method> methods;

private:
    virtual ~SourceProviderInterfaceTypeEntityPad() throw () {}
};

class SourceProviderConstantGroupEntityPad: public SourceProviderEntityPad {
public:
    explicit SourceProviderConstantGroupEntityPad(bool published):
        SourceProviderEntityPad(published)
    {}

    std::vector<unoidl::ConstantGroupEntity::Member> members;

private:
    virtual ~SourceProviderConstantGroupEntityPad() throw () {}
};<commit_msg>WaE: C4805: '!=' : unsafe mix of type 'bool' and type 'sal_Bool' in operation<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_UNOIDL_SOURCE_SOURCEPROVIDER_SCANNER_HXX
#define INCLUDED_UNOIDL_SOURCE_SOURCEPROVIDER_SCANNER_HXX

#include "sal/config.h"

#include <cassert>
#include <map>
#include <vector>

#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "salhelper/simplereferenceobject.hxx"
#include "unoidl/unoidl.hxx"

#include "sourceprovider-parser-requires.hxx"
#include "sourceprovider-parser.hxx"

namespace unoidl { namespace detail {

class SourceProviderEntityPad: public salhelper::SimpleReferenceObject {
public:
    bool isPublished() const { return published_; }

protected:
    explicit SourceProviderEntityPad(bool published): published_(published) {}

    virtual ~SourceProviderEntityPad() {}

private:
    bool const published_;
};

class SourceProviderEnumTypeEntityPad: public SourceProviderEntityPad {
public:
    explicit SourceProviderEnumTypeEntityPad(bool published):
        SourceProviderEntityPad(published)
    {}

    std::vector<unoidl::EnumTypeEntity::Member> members;

private:
    virtual ~SourceProviderEnumTypeEntityPad() throw () {}
};

class SourceProviderPlainStructTypeEntityPad: public SourceProviderEntityPad {
public:
    SourceProviderPlainStructTypeEntityPad(
        bool published, OUString theBaseName,
        rtl::Reference<unoidl::PlainStructTypeEntity> const & theBaseEntity):
        SourceProviderEntityPad(published), baseName(theBaseName),
        baseEntity(theBaseEntity)
    { assert(theBaseName.isEmpty() != (bool) theBaseEntity.is()); }

    OUString const baseName;
    rtl::Reference<unoidl::PlainStructTypeEntity> const baseEntity;
    std::vector<unoidl::PlainStructTypeEntity::Member> members;

private:
    virtual ~SourceProviderPlainStructTypeEntityPad() throw () {}
};

class SourceProviderPolymorphicStructTypeTemplateEntityPad:
    public SourceProviderEntityPad
{
public:
    SourceProviderPolymorphicStructTypeTemplateEntityPad(bool published):
        SourceProviderEntityPad(published)
    {}

    std::vector<OUString> typeParameters;
    std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member> members;

private:
    virtual ~SourceProviderPolymorphicStructTypeTemplateEntityPad() throw () {}
};

class SourceProviderExceptionTypeEntityPad: public SourceProviderEntityPad {
public:
    SourceProviderExceptionTypeEntityPad(
        bool published, OUString theBaseName,
        rtl::Reference<unoidl::ExceptionTypeEntity> const & theBaseEntity):
        SourceProviderEntityPad(published), baseName(theBaseName),
        baseEntity(theBaseEntity)
    { assert(theBaseName.isEmpty() != (bool) theBaseEntity.is()); }

    OUString const baseName;
    rtl::Reference<unoidl::ExceptionTypeEntity> const baseEntity;
    std::vector<unoidl::ExceptionTypeEntity::Member> members;

private:
    virtual ~SourceProviderExceptionTypeEntityPad() throw () {}
};

class SourceProviderInterfaceTypeEntityPad: public SourceProviderEntityPad {
public:
    struct Base {
        Base(
            OUString const & theName,
            rtl::Reference<unoidl::InterfaceTypeEntity> const & theEntity,
            std::vector<OUString> const & theAnnotations):
            name(theName), entity(theEntity), annotations(theAnnotations)
        {}

        OUString name;
        rtl::Reference<unoidl::InterfaceTypeEntity> entity;
        std::vector<OUString> annotations;
    };

    SourceProviderInterfaceTypeEntityPad(
        bool published, OUString singleBaseName,
        rtl::Reference<unoidl::InterfaceTypeEntity> const & singleBaseEntity):
        SourceProviderEntityPad(published),
        singleBase(!singleBaseName.isEmpty())
    {
        assert(singleBaseName.isEmpty() != (bool) singleBaseEntity.is());
        if (singleBase) {
            mandatoryBases.push_back(
                Base(
                    singleBaseName, singleBaseEntity, std::vector<OUString>()));
        }
    }

    bool singleBase;
    std::vector<Base> mandatoryBases;
    std::vector<Base> optionalBases;
    std::vector<unoidl::InterfaceTypeEntity::Attribute> attributes;
    std::vector<unoidl::InterfaceTypeEntity::Method> methods;

private:
    virtual ~SourceProviderInterfaceTypeEntityPad() throw () {}
};

class SourceProviderConstantGroupEntityPad: public SourceProviderEntityPad {
public:
    explicit SourceProviderConstantGroupEntityPad(bool published):
        SourceProviderEntityPad(published)
    {}

    std::vector<unoidl::ConstantGroupEntity::Member> members;

private:
    virtual ~SourceProviderConstantGroupEntityPad() throw () {}
};
{'fraction_non_alphanumeric': 0.10067930649903681, 'fraction_numerical': 0.0016222244753117713, 'mean_word_length': 4.672225416906268, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '4999100', 'n_tokens_mistral': 2793, 'n_tokens_neox': 2707, 'n_words': 548}