/********************************************************************************\
**                                                                              **
**  Copyright (C) 2008 Josh Ventura                                             **
**                                                                              **
**  This file is a part of the ENIGMA Development Environment.                  **
**                                                                              **
**                                                                              **
**  ENIGMA is free software: you can redistribute it and/or modify it under the **
**  terms of the GNU General Public License as published by the Free Software   **
**  Foundation, version 3 of the license or any later version.                  **
**                                                                              **
**  This application and its source code is distributed AS-IS, WITHOUT ANY      **
**  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS   **
**  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more       **
**  details.                                                                    **
**                                                                              **
**  You should have recieved a copy of the GNU General Public License along     **
**  with this code. If not, see <http://www.gnu.org/licenses/>                  **
**                                                                              **
**  ENIGMA is an environment designed to create games and other programs with a **
**  high-level, fully compilable language. Developers of ENIGMA or anything     **
**  associated with ENIGMA are in no way responsible for its users or           **
**  applications created by its users, or damages caused by the environment     **
**  or programs made in the environment.                                        **
**                                                                              **
\********************************************************************************/

#include <string>
#include <cstdio>
using namespace std;

typedef size_t pt;

string tostring(int val)
{
  char a[12];
  sprintf(a,"%d",val);
  return a;
}
string tostringd(double val)
{
  char a[24];
  sprintf(a,"%f",val);
  return a;
}
string tostringv(void* val)
{
  char a[24];
  sprintf(a,"%p",val);
  return a;
}

string arraybounds_as_str(string str)
{
  string ret;
  for (pt i=0;i<str.length();i++)
  {
    if (str[i]=='[') ret+="arrayb";
    else if (str[i]==')') ret+="eparenth";
    else if (str[i]=='(') ret+="fparenth";
  }
  return ret;
}

int string_count(char c, char* str)
{
    int occ = 0;
    while (*str) occ+=*(str++)==c;
    return occ;
}
/* */
