#include "Dictionary.h"
#include "definition.h"

Dictionary<DictionaryHelper::StringEntity> *DictionaryHelper::StringEntity::split(char character)
{
  Dictionary<DictionaryHelper::StringEntity> *ref = NULL;
  unsigned int i(0), counter(0);
  char *parseBuffer(NULL);
  
  if(_string == NULL)return NULL;

  ref = new Dictionary<StringEntity>();

  while(_string[i] != '\0')
  {
    if(_string[i] == character)
    {
      ref->add(counter++, parseBuffer);
      free(parseBuffer);parseBuffer = NULL;
    }
    else
    {
      parseBuffer = addChar(parseBuffer, _string[i]);
    }
    
    i++;
  }

  ref->add(counter++,parseBuffer);
  free(parseBuffer);parseBuffer = NULL;
  
  return ref;
}
