<commit_before>/*---------------------------------------------------------------------------*\
 *                                OpenSG                                     *
 *                                                                           *
 *                                                                           *
 *           Copyright (C) 2000,2001,2002 by the OpenSG Forum                *
 *                                                                           *
 *                            www.opensg.org                                 *
 *                                                                           *
 *   contact: <EMAIL>, <EMAIL>, <EMAIL>          *
 *                                                                           *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
 *                                License                                    *
 *                                                                           *
 * This library is free software; you can redistribute it and/or modify it   *
 * under the terms of the GNU Library General Public License as published    *
 * by the Free Software Foundation, version 2.                               *
 *                                                                           *
 * This library is distributed in the hope that it will be useful, but       *
 * WITHOUT ANY WARRANTY; without even the implied warranty of                *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
 * Library General Public License for more details.                          *
 *                                                                           *
 * You should have received a copy of the GNU Library General Public         *
 * License along with this library; if not, write to the Free Software       *
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
 *                                                                           *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
 *                                Changes                                    *
 *                                                                           *
 *                                                                           *
 *                                                                           *
 *                                                                           *
 *                                                                           *
 *                                                                           *
\*---------------------------------------------------------------------------*/

#include <cstdlib>
#include <cstdio>

#include "OSGConfig.h"

#include "OSGAttachmentContainer.h"
#include "OSGNameAttachment.h"

OSG_BEGIN_NAMESPACE

template <>
SimpleAttachment<NameAttachmentDesc>::TypeObject &
    SimpleAttachment<NameAttachmentDesc>::getType(void)
{
    return _type;
}

template <>
const SimpleAttachment<NameAttachmentDesc>::TypeObject &
    SimpleAttachment<NameAttachmentDesc>::getType(void) const
{
    return _type;
}

template <>
SimpleAttachment<NameAttachmentDesc>::TypeObject &
    SimpleAttachment<NameAttachmentDesc>::getClassType(void)
{
    return _type;
}

OSG_SIMPLEATTACHMENT_INST(NameAttachmentDesc);

/*-------------------------------------------------------------------------*/
/*                   Name Attachment Utility Functions                     */

/*! 
  Return the name attached to the container, NULL if none attached or
  container is NULL.
 */

const Char8 *getName(AttachmentContainer * const pContainer)
{
    if(pContainer == NULL)
        return NULL;
   
    // Get attachment pointer
    Attachment *att = 
        pContainer->findAttachment(Name::getClassType().getGroupId());

    if(att == NULL)
        return NULL;
   
    // Cast to name pointer                           

    Name *name = dynamic_cast<Name *>(att);

    if(name == NULL)
        return NULL;
   
    return name->getFieldPtr()->getValue().c_str();
}

/*! Set the name attached to the container. If the container doesn't have a
    name attachement yet one is created. 
 */

void setName(AttachmentContainer * const  pContainer, 
             std::string           const &namestring)
{
    if(pContainer == NULL)
    {
        FFATAL(("setName: no container?!?"));
        return;
    }
   
    // Get attachment pointer

    NameUnrecPtr  name = NULL;
    Attachment   *att  = 
        pContainer->findAttachment(Name::getClassType().getGroupId());
    
    if(att == NULL)
    {
        name = Name::createDependent(
            pContainer->getFieldFlags()->_bNamespaceMask);

        pContainer->addAttachment(name);
    }
    else
    {   
        name = dynamic_cast<Name *>(att);

        if(name == NULL)
        {
            FFATAL(("setName: Name Attachment is not castable to Name?!?"));
            return;
        }
    }
    
  
    name->editFieldPtr()->getValue().assign(namestring);   
}

/*! 
  Set the name attached to the container. If the container doesn't have 
  name attachement yet one is created. If the name is NULL, an attached
  name is removed.
 */

void setName(AttachmentContainer * const pContainer, const Char8 *name)
{
    if(name == NULL)
    {
        Attachment *att = 
            pContainer->findAttachment(Name::getClassType().getGroupId());
 
        if(att != NULL)
        {
            pContainer->subAttachment(att);<commit_msg>[PATCH 14/36] fixed: missing newline in error msg<commit_after>/*---------------------------------------------------------------------------*\
 *                                OpenSG                                     *
 *                                                                           *
 *                                                                           *
 *           Copyright (C) 2000,2001,2002 by the OpenSG Forum                *
 *                                                                           *
 *                            www.opensg.org                                 *
 *                                                                           *
 *   contact: <EMAIL>, <EMAIL>, <EMAIL>          *
 *                                                                           *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
 *                                License                                    *
 *                                                                           *
 * This library is free software; you can redistribute it and/or modify it   *
 * under the terms of the GNU Library General Public License as published    *
 * by the Free Software Foundation, version 2.                               *
 *                                                                           *
 * This library is distributed in the hope that it will be useful, but       *
 * WITHOUT ANY WARRANTY; without even the implied warranty of                *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
 * Library General Public License for more details.                          *
 *                                                                           *
 * You should have received a copy of the GNU Library General Public         *
 * License along with this library; if not, write to the Free Software       *
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
 *                                                                           *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
 *                                Changes                                    *
 *                                                                           *
 *                                                                           *
 *                                                                           *
 *                                                                           *
 *                                                                           *
 *                                                                           *
\*---------------------------------------------------------------------------*/

#include <cstdlib>
#include <cstdio>

#include "OSGConfig.h"

#include "OSGAttachmentContainer.h"
#include "OSGNameAttachment.h"

OSG_BEGIN_NAMESPACE

template <>
SimpleAttachment<NameAttachmentDesc>::TypeObject &
    SimpleAttachment<NameAttachmentDesc>::getType(void)
{
    return _type;
}

template <>
const SimpleAttachment<NameAttachmentDesc>::TypeObject &
    SimpleAttachment<NameAttachmentDesc>::getType(void) const
{
    return _type;
}

template <>
SimpleAttachment<NameAttachmentDesc>::TypeObject &
    SimpleAttachment<NameAttachmentDesc>::getClassType(void)
{
    return _type;
}

OSG_SIMPLEATTACHMENT_INST(NameAttachmentDesc);

/*-------------------------------------------------------------------------*/
/*                   Name Attachment Utility Functions                     */

/*! 
  Return the name attached to the container, NULL if none attached or
  container is NULL.
 */

const Char8 *getName(AttachmentContainer * const pContainer)
{
    if(pContainer == NULL)
        return NULL;
   
    // Get attachment pointer
    Attachment *att = 
        pContainer->findAttachment(Name::getClassType().getGroupId());

    if(att == NULL)
        return NULL;
   
    // Cast to name pointer                           

    Name *name = dynamic_cast<Name *>(att);

    if(name == NULL)
        return NULL;
   
    return name->getFieldPtr()->getValue().c_str();
}

/*! Set the name attached to the container. If the container doesn't have a
    name attachement yet one is created. 
 */

void setName(AttachmentContainer * const  pContainer, 
             std::string           const &namestring)
{
    if(pContainer == NULL)
    {
        FFATAL(("setName: no container?!?\n"));
        return;
    }
   
    // Get attachment pointer

    NameUnrecPtr  name = NULL;
    Attachment   *att  = 
        pContainer->findAttachment(Name::getClassType().getGroupId());
    
    if(att == NULL)
    {
        name = Name::createDependent(
            pContainer->getFieldFlags()->_bNamespaceMask);

        pContainer->addAttachment(name);
    }
    else
    {   
        name = dynamic_cast<Name *>(att);

        if(name == NULL)
        {
            FFATAL(("setName: Name Attachment is not castable to Name?!?\n"));
            return;
        }
    }
    
  
    name->editFieldPtr()->getValue().assign(namestring);   
}

/*! 
  Set the name attached to the container. If the container doesn't have 
  name attachement yet one is created. If the name is NULL, an attached
  name is removed.
 */

void setName(AttachmentContainer * const pContainer, const Char8 *name)
{
    if(name == NULL)
    {
        Attachment *att = 
            pContainer->findAttachment(Name::getClassType().getGroupId());
 
        if(att != NULL)
        {
            pContainer->subAttachment(att);
{'fraction_non_alphanumeric': 0.16533240515140968, 'fraction_numerical': 0.00435085276714236, 'mean_word_length': 0.8819387588013755, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 102, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5394037', 'n_tokens_mistral': 2296, 'n_tokens_neox': 2237, 'n_words': 618}