<commit_before>/*
  NUI3 - C++ cross-platform GUI framework for OpenGL based applications
  Copyright (C) 2002-2003 <NAME>

  licence: see nui3/LICENCE.TXT
*/

#pragma once

enum nuiTokenType
{
  eTokenUnkown,
  eTokenInt32,
  eTokenInt64,
  eTokenUInt32,
  eTokenUInt64,
  eTokenFloat,
  eTokenDouble,
  eTokenPointer,
  eTokenString
};

template<class T> class nuiTokenTrait
{
public:
  static nuiTokenType GetType()
  {
    return eTokenUnkown;
  }
};

class nuiTokenBase
{
public:
  nuiTokenBase()
  {
    mType = eTokenUnkown;
  }

  virtual ~nuiTokenBase()
  {
  }
  
  nuiTokenType GetType() const
  {
    return mType;
  }
  
protected:
  nuiTokenType mType;
};

template <class T> class nuiToken : public nuiTokenBase
{
public:
  nuiToken(const T& rToken)
  : Token(rToken)
  {
    mType = nuiTokenTrait<T>::GetType();
  }
  
  const T Token; 
};

template <typename T> class nuiToken<T*> : public nuiTokenBase
{
public:
  nuiToken(T* pToken, bool OwnToken = false)
  : Token(pToken), mOwnToken(OwnToken)
  {
    mType = eTokenPointer;
  }
  
  ~nuiToken()
  {
    if (mOwnToken)
      delete Token;
  }
  
  T* const Token;
  bool mOwnToken;
};


class nuiTokenHolder
{
public:
  nuiTokenHolder()
  {
    mpToken = NULL;
  }
  
  virtual ~nuiTokenHolder()
  {
    delete mpToken;
  }
  
  void SetToken(nuiTokenBase* pToken)
  {
    if (mpToken != pToken)
      delete mpToken;
    mpToken = pToken;
  }
  
  nuiTokenBase* GetToken() const
  {
    return mpToken;  
  }
private:
  nuiTokenBase* mpToken;
};


 
template <class T>
bool nuiGetTokenValue (nuiTokenBase* pTokenBase, T& rValue)
{
  nuiToken<T>* pToken = dynamic_cast<nuiToken<T>*>(pTokenBase);
  
  if (pToken)
  {
    rValue = pToken->Token;
    return true;
  }
  
  return false;
}
<commit_msg>application selection is ok now next step: save the configuration<commit_after>/*
  NUI3 - C++ cross-platform GUI framework for OpenGL based applications
  Copyright (C) 2002-2003 <NAME>

  licence: see nui3/LICENCE.TXT
*/

#pragma once

enum nuiTokenType
{
  eTokenUnkown,
  eTokenInt32,
  eTokenInt64,
  eTokenUInt32,
  eTokenUInt64,
  eTokenFloat,
  eTokenDouble,
  eTokenPointer,
  eTokenString
};

template<class T> class nuiTokenTrait
{
public:
  static nuiTokenType GetType()
  {
    return eTokenUnkown;
  }
};

class nuiTokenBase
{
public:
  nuiTokenBase()
  {
    mType = eTokenUnkown;
  }

  virtual ~nuiTokenBase()
  {
  }
  
  nuiTokenType GetType() const
  {
    return mType;
  }
  
protected:
  nuiTokenType mType;
};

template <class T> class nuiToken : public nuiTokenBase
{
public:
  nuiToken(const T& rToken)
  : Token(rToken)
  {
    mType = nuiTokenTrait<T>::GetType();
  }
  
  const T Token; 
};

template <class T> class nuiFreeToken : public nuiTokenBase
{
public:
  nuiFreeToken(const T& rToken)
  : Token(rToken)
  {
    mType = nuiTokenTrait<T>::GetType();
  }

  const T Token;
};


template <typename T> class nuiToken<T*> : public nuiTokenBase
{
public:
  nuiToken(T* pToken, bool OwnToken = false)
  : Token(pToken), mOwnToken(OwnToken)
  {
    mType = eTokenPointer;
  }
  
  ~nuiToken()
  {
    if (mOwnToken)
      delete Token;
  }
  
  T* const Token;
  bool mOwnToken;
};


class nuiTokenHolder
{
public:
  nuiTokenHolder()
  {
    mpToken = NULL;
  }
  
  virtual ~nuiTokenHolder()
  {
    delete mpToken;
  }
  
  void SetToken(nuiTokenBase* pToken)
  {
    if (mpToken != pToken)
      delete mpToken;
    mpToken = pToken;
  }
  
  nuiTokenBase* GetToken() const
  {
    return mpToken;  
  }
private:
  nuiTokenBase* mpToken;
};


 
template <class T>
bool nuiGetTokenValue (nuiTokenBase* pTokenBase, T& rValue)
{
  {
    nuiToken<T>* pToken = dynamic_cast<nuiToken<T>*>(pTokenBase);
    
    if (pToken)
    {
      rValue = pToken->Token;
      return true;
    }
  }
  
  {
    nuiFreeToken<T>* pToken = dynamic_cast<nuiFreeToken<T>*>(pTokenBase);

    if (pToken)
    {
      rValue = pToken->Token;
      return true;
    }
  }

  return false;
}

{'fraction_non_alphanumeric': 0.1094577553593947, 'fraction_numerical': 0.009079445145018916, 'mean_word_length': 3.0101112234580385, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 31, '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': '3172950', 'n_tokens_mistral': 1594, 'n_tokens_neox': 1555, 'n_words': 331}