Ejemplo n.º 1
0
Chaine Chaine::sous_chaine(int ind_deb, int ind_fin){
	int l = this->len();

	if (ind_deb < 0 || ind_fin > l){
		return Chaine();
	}
	
	return Chaine(*this, ind_deb, ind_fin);
}
 BaseTemplate TypeTemplate::TemplateDeBase() const
 {
 
   Chaine nom(this->classeTemplate->Name()->ToString()) ;
   
   rDebug(nom) ;
   
   if (nom == Chaine("Association"))
     return Compilateur::Association ;
   else if (nom == Chaine("Composition"))
     return Compilateur::Composition ;
   else if (nom == Chaine("EnsembleComposition"))
     return Compilateur::EnsembleComposition ;
   else if (nom == Chaine("EnsembleAssociation"))
     return Compilateur::EnsembleAssociation ;
   else if (nom == Chaine("FonctionObjetValeur"))
     return Compilateur::FonctionObjetValeur ;
   else if (nom == Chaine("FonctionCompositionObjetObjet"))
     return Compilateur::FonctionCompositionObjetObjet ;
   else if (nom == Chaine("FonctionAssociationObjetObjet"))
     return Compilateur::FonctionAssociationObjetObjet ;
   else if (nom == Chaine("FonctionCompositionValeurObjet"))
     return Compilateur::FonctionCompositionValeurObjet ;
   else if (nom == Chaine("FonctionAssociationValeurObjet"))
     return Compilateur::FonctionAssociationValeurObjet ;
   
   else
     return Compilateur::NonPrisEnCompte ;
 }
      Chaine TypeTemplate::Afficher() const
      {
        
        rDebug("TypeTemplate::Afficher") ;
        
        Chaine resultat(NomComplet(this->espaceDeNom)) ;

        rDebug("TypeTemplate::Afficher 2") ;        

        Chaine sortieParametres ;
//        if (parametres)
//          sortieParametres = (parametres->ToString()) ;

        for(IterateurListeComposition<ParametreTemplate> parametre(this->_parametres) ;
            parametre.Valide() ;
            ++parametre)
        {
        
          sortieParametres += ',' ;
          sortieParametres += parametre->Afficher() ;
          rDebug("parametre = " + parametre->Afficher()) ;
        }


        rDebug("fin TypeTemplate::Afficher") ;
        
        return "template " + resultat + Chaine("::") + 
               classeTemplate->Name()->ToString() + 
               "<" + sortieParametres +">" ;

        
      }
Ejemplo n.º 4
0
Chaine Chaine::operator+(Chaine b){
	Chaine result = Chaine();

	result += *this;
	result += b;

	return result;
}
Ejemplo n.º 5
0
 Modele::~Modele()
 {
   
   Traceur::MessageInterne(Chaine(observateurs.NombreDElements()) + " elements") ;
   for(IterateurEnsembleAssociation<Implantation::BaseVue> vue(observateurs) ;
       vue.Valide() ;
       ++vue)
   {
     vue->MarquerADetruire() ;
   }  
   
 }
     Base::Booleen TypeTemplate::NamespaceProjetUniversBase() const
     {
       Environment* courant = this->classeTemplate->GetEnvironment() ;
       Environment* precedent ;
       
       while (courant->GetOuterEnvironment() != NULL 
              && courant->GetOuterEnvironment()->IsNamespace() != NULL)
       {       
         precedent = courant ;
         courant = courant->GetOuterEnvironment() ;
       
       }
       
       if (Chaine(courant->IsNamespace()->ToString()) == Chaine("ProjetUnivers")
           && Chaine(precedent->IsNamespace()->ToString()) == Chaine("Base"))
       
         return true ;
       
       else
         
         return false ;
 
       
     }
        void TestListe::TestAjouter()
        {
  	      // 
          ListeAssociation< ElementTestListe > temp ;
  
          Composition< ElementTestListe > element1(new ElementTestListe(1)) ;
          Composition< ElementTestListe > element2(new ElementTestListe(2)) ;
  
          temp.AjouterEnTete(element1) ;
          temp.AjouterEnTete(element2) ;
  
          CPPUNIT_ASSERT(temp.NombreDElements() == 2) ;
  
          CPPUNIT_ASSERT(temp.Contient(element1)) ;
          CPPUNIT_ASSERT(temp.Contient(element2)) ;
  
          Entier resultat(0) ;
  
          for(
            IterateurListeAssociation< ElementTestListe > i(temp) ;
            i.Valide() ;
            ++i)
          {
            resultat += i->valeur ;
          }
          
          CPPUNIT_ASSERT(resultat == 3) ;

          // liste de valeurs
   
          listeChaine.AjouterEnTete("toto") ;
          listeChaine.AjouterEnTete("titi") ;
  
          CPPUNIT_ASSERT(listeChaine.Contient("toto")) ;
          CPPUNIT_ASSERT(listeChaine.Contient("titi")) ;
          
          // test de l'itérateur
          
          IterateurListeValeur<Chaine> chaine(listeChaine) ;

          CPPUNIT_ASSERT(chaine == Chaine("titi")) ;
          ++chaine ;

          CPPUNIT_ASSERT(chaine == "toto") ;
          
        }
      Booleen Attribut::VerifieRegles() const 
      {
        
        if (this->type != 0)
        {
          
          Booleen validiteType(type->TypeAttributCorrect()) ;

          if ( ! validiteType)
          {
            
            char* nomCString = (char *)malloc(sizeof(char)*(nom.Longueur() +1)) ;
            strcpy(nomCString, nom) ;
            
            Ptree* ArbreNom = (new Leaf(nomCString,
                               nom.Longueur())) ;
                               
                               
            
            
            Chaine message = "dans la classe : " + Chaine(classe->Name()->ToString()) + 
                             " l'attribut " + membre.Name()->ToString() + 
                             " a un type interdit" ;

            rDebug(message) ;
            
            classe->ErrorMessage(
                                 classe->GetEnvironment()->GetOuterEnvironment(), 
                                 "type d'attribut incorrect:", 
                                 membre.Name(), 
                                 membre.Name()) ;
                                   
          }

          /*!
            \todo
              vérifier que le nom est bien un identificateur dans les 
              bonnes formes
          */
          Booleen validiteNom(VRAI) ;
          
          return validiteType && validiteNom ;
        }
        else
          return FAUX ;
      }
Ejemplo n.º 9
0
int main()
{
    mpz_t pN;
    mpz_init(pN);
    mpz_t puC;
    mpz_init(puC);
    mpz_t prU;
    mpz_init(prU);

    gmp_randstate_t state;
    gmp_randinit_default(state);

    mpz_t seed;
    mpz_init(seed);

    RSA KeyGenerator;

    KeyGenerator.randInit(seed,"ahahah");
    gmp_randseed(state,seed);

    std::cout << "état : " <<state <<std::endl;

    KeyGenerator.getKeys(pN, puC, prU, state);

    std::cout << "public keys : " <<pN <<std::endl<<puC<<std::endl;
    std::cout << "private keys : " <<pN <<std::endl<<prU<<std::endl;

    gmp_randclear(state);

    Message Chaine("s");
    mpz_t code;
    mpz_init(code);
    std::string text1 = Chaine.encryptRSA(puC,pN);

    //std::cout << "voici le texte crypté:"<<std::endl<<text1<<std::endl;

    std::string text2 = Chaine.decryptRSA(prU, pN);
    //std::cout << "voici le texte décrypté:"<<std::endl<<text2<<std::endl;

    return 0;
}
 Chaine Exception::Message() const {
 
   return Chaine("ERREUR") + Chaine(numeroErreur) + Chaine(" : ") + message;
 }
     /// Transforme en chaine pour l'affichage.
 Chaine TypeEnumere::Afficher() const
 {
   return "enumere " + Chaine(this->elements->ToString()) ;  
 }