#include "clef.h"

CClef::CClef(string alpha):num(0){

	if(alpha.size() < 30)
		throw "Taill de cle invalide";

	for(int i=0; i<CLEFSIZE; i++){
		Alpha_Num[i] = alpha[i];
	}
	Alpha_Num[CLEFSIZE] = '\0';

	makeNum();
}


void CClef::makeNum(){


	
	int temp;
	
	for(int i = 0; i<CLEFSIZE;i+=2){	
		
		if((!check(Alpha_Num[i]))||(!check(Alpha_Num[i+1])))
			throw "invalid char";

		stringstream str;
		str<<(int)Alpha_Num[i];
		str<<(int)Alpha_Num[i+1];
		str>>temp;
		
		/*
		cout<<(int)Alpha_Num[i]<<endl;
		cout<<(int)Alpha_Num[i+1]<<endl;
		cout<<temp<<endl;*/
		num += temp;		
	}
}




bool CClef::check(char a){
	
		if((a < '0')||(a >'z')) return false;
		if((a > '9')&&(a <'A')) return false;
		if((a > 'Z')&&(a <'a')) return false;

		return true;
}

CClef::~CClef(void)
{
}
