<commit_before>// Copyright (C) 2016 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

#include "copasi.h"

#include "UnitDefinitionHandler.h"
#include "CXMLParser.h"
#include "utilities/CCopasiMessage.h"

#include "utilities/CUnitDefinition.h"

/**
 * Replace UnitDefinition with the name type of the handler and implement the
 * three methods below.
 */
UnitDefinitionHandler::UnitDefinitionHandler(CXMLParser & parser, CXMLParserData & data):
  CXMLHandler(parser, data, CXMLHandler::UnitDefinition),
  mKey()
{
  init();
}

// virtual
UnitDefinitionHandler::~UnitDefinitionHandler()
{}

// virtual
CXMLHandler * UnitDefinitionHandler::processStart(const XML_Char * pszName,
    const XML_Char ** papszAttrs)
{
  CXMLHandler * pHandlerToCall = NULL;
  const char * Name;
  const char * Symbol;

  switch (mCurrentElement.first)
    {
      case UnitDefinition:
        // Element specific code.
        mKey = mpParser->getAttributeValue("key", papszAttrs);
        Name = mpParser->getAttributeValue("name", papszAttrs);
        Symbol = mpParser->getAttributeValue("symbol", papszAttrs);

        // Need a CUnitDefinition.
        // This is manipulated in this case and the Expression case.
        // No test for NULL here. If this already was pointing to something,
        // we don't want that object for this.
        mpData->pCurrentUnitDefinition = new CUnitDefinition(Name, NULL);
        mpData->pCurrentUnitDefinition->setSymbol(Symbol);

        break;;

      case MiriamAnnotation:
      case Comment:
      case ListOfUnsupportedAnnotations:
      case Expression:
        pHandlerToCall = getHandler(mCurrentElement.second);<commit_msg>Bug 2534. User defined symbols are now correctly loaded and displayed.<commit_after>// Copyright (C) 2017 - 2018 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.

// Copyright (C) 2016 by <NAME>, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.

#include "copasi.h"

#include "copasi/xml/parser/UnitDefinitionHandler.h"
#include "copasi/xml/parser/CXMLParser.h"
#include "copasi/utilities/CCopasiMessage.h"

#include "copasi/utilities/CUnitDefinition.h"
#include "copasi/utilities/CUnitDefinitionDB.h"
/**
 * Replace UnitDefinition with the name type of the handler and implement the
 * three methods below.
 */
UnitDefinitionHandler::UnitDefinitionHandler(CXMLParser & parser, CXMLParserData & data):
  CXMLHandler(parser, data, CXMLHandler::UnitDefinition),
  mKey()
{
  init();
}

// virtual
UnitDefinitionHandler::~UnitDefinitionHandler()
{}

// virtual
CXMLHandler * UnitDefinitionHandler::processStart(const XML_Char * pszName,
    const XML_Char ** papszAttrs)
{
  CXMLHandler * pHandlerToCall = NULL;
  const char * Name;
  const char * Symbol;

  switch (mCurrentElement.first)
    {
      case UnitDefinition:
        // Element specific code.
        mKey = mpParser->getAttributeValue("key", papszAttrs);
        Name = mpParser->getAttributeValue("name", papszAttrs);
        Symbol = mpParser->getAttributeValue("symbol", papszAttrs);

        // Need a CUnitDefinition.
        // This is manipulated in this case and the Expression case.
        // No test for NULL here. If this already was pointing to something,
        // we don't want that object for this.
        mpData->pCurrentUnitDefinition = new CUnitDefinition(Name, NULL);
        mpData->pCurrentUnitDefinition->setSymbol(Symbol);
        mpData->pUnitDefinitionImportList->add(mpData->pCurrentUnitDefinition, true);
        break;;

      case MiriamAnnotation:
      case Comment:
      case ListOfUnsupportedAnnotations:
      case Expression:
        pHandlerToCall = getHandler(mCurrentElement.second);
{'fraction_non_alphanumeric': 0.10091277890466531, 'fraction_numerical': 0.005070993914807302, 'mean_word_length': 3.6964285714285716, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1778028', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1087, 'n_words': 316}