Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1271 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  [C++] Bibliothèque Argstream : arguments de la ligne de commande

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[C++] Bibliothèque Argstream : arguments de la ligne de commande

n°890248
Evadream -​jbd-
Posté le 04-11-2004 à 14:55:33  profilanswer
 

Hello tout le monde,
 
Voici une bibliothèque en GPL bien sympathique que j'utilise systématiquement depuis quelques temps maintenant. Elle permet de parser les arguments en ligne de commande d'un programme C++. Son utilisation est vraiment très agréable (un unique .h à inclure), et sa documentation extremement claire, avec tout plein d'exemples.  
 
La page du projet sur freshmeat :
http://freshmeat.net/projects/argstream/
 
La page de documentation :
http://artis.imag.fr/Membres/Xavie [...] argstream/
 
Son auteur propose par ailleurs un excellent tutorial STL :
http://artis.imag.fr/Membres/Xavie [...] _tutorial/
 

mood
Publicité
Posté le 04-11-2004 à 14:55:33  profilanswer
 

n°1784279
gerfaut
Posté le 09-09-2008 à 09:52:43  profilanswer
 

Bonjour,
 
J'ai essayé cette bibliothèque C++, et je dois dire que c'est assez bien fait. Le seul problème, c'est que je n'arrive pas à compiler l'exemple basique qui est fourni :

Code :
  1. #include <argstream.h>
  2. using namespace std;
  3. int
  4. main(int argc,char** argv)
  5. {
  6.   // The variables you want to initialize/set from command line
  7.   bool verbose;
  8.   int  level = 1;
  9.   string outputName;
  10.   deque<string> inputNames; 
  11.   // Using the argstream to retrieve this information
  12.   argstream as(argc,argv);
  13.  
  14.   as>>option('v',"verbose",verbose,"Activate verbose mode" )
  15.     >>parameter('l',"level",level,"Level of treatment",false)
  16.     >>parameter('o',"out",outputName,"Where to save result" )
  17.     >>values<string>(back_inserter(inputNames),"Files to process" )
  18.     >>help();
  19.  
  20.   as.defaultErrorHandling();
  21.   // Your program
  22.   // ...
  23.   // ...
  24.   // ...
  25. }


Je n'ai aucun problème avec les 'option' et les 'parameter', mais dès que je veux des champs 'values', j'ai des pages d'erreurs de templates qui ne sont pas définis etc...
 
Est-ce que quelqu'un saurait me dire pourquoi ?
Précision, je compile avec GNU/gcc sous Cygwin.
 
Voici les erreurs que génère gcc :

argstream.h: In instantiation of `<unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >':
basic_example.cpp:19:   instantiated from here
argstream.h:169: error: template-id `operator>><>' for `<unnamed>::argstream& <unnamed>::operator>>(<unnamed>::argstream&, const <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >& )' does not match any template declaration
argstream.h: In function `<unnamed>::argstream& <unnamed>::operator>>(<unnamed>::argstream&, const <unnamed>::ValuesHolder<T, O>& ) [with T = std::string, O = std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > >]':
basic_example.cpp:20:   instantiated from here
argstream.h:177: error: `char <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::letter_' is private
argstream.h:743: error: within this context
argstream.h:176: error: `int <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::len_' is private
argstream.h:744: error: within this context
argstream.h:176: error: `int <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::len_' is private
argstream.h:752: error: within this context
argstream.h:177: error: `char <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::letter_' is private
argstream.h:752: error: within this context
basic_example.cpp:20:   instantiated from here
argstream.h:176: error: `int <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::len_' is private
argstream.h:760: error: within this context
argstream.h:176: error: `int <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::len_' is private
argstream.h:760: error: within this context
basic_example.cpp:20:   instantiated from here
argstream.h:174: error: `std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::value_' is private
argstream.h:765: error: within this context
basic_example.cpp:20:   instantiated from here
argstream.h:176: error: `int <unnamed>::ValuesHolder<std::string, std::back_insert_iterator<std::deque<std::string, std::allocator<std::string> > > >::len_' is private
argstream.h:784: error: within this context


Pardon pour ce post un peu long.

n°1784306
Joel F
Real men use unique_ptr
Posté le 09-09-2008 à 10:42:59  profilanswer
 

boost::program_options quoi :/


Message édité par Joel F le 09-09-2008 à 10:43:10
n°1785752
gerfaut
Posté le 11-09-2008 à 18:41:15  profilanswer
 

Merci pour le conseil, je vais voir si j'ai plus de réussite avec boost !

n°1792892
Evadream -​jbd-
Posté le 27-09-2008 à 22:59:19  profilanswer
 

C'est vieux tout ça [:ddr555] ! boost::program_options à 100%, j'étais jeune et fou à l'époque, je n'avais pas vu la lumière.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  [C++] Bibliothèque Argstream : arguments de la ligne de commande

 

Sujets relatifs
ajout ligne dansun fichier texteecrire dans fichier texte sans retour à la ligne
Aprrendre java en ligne par la pratiqueCommande INTERFAC TO SUBROUTINE (Vis. Fort.) à remplacer sous Linux
preg_replace et balises à arguments variablesUtilisation d'une redirection en utilisant une commande JS
[e-Commerce] Faites gaffe aux prestataires de paiment en ligne[HTML/CSS] DIV et "retour à la ligne"
[Oracle Text Search] Vous avez une doc en ligne ?[Réglé] Espacement, saut de ligne>>MySQL>>Affichage
Plus de sujets relatifs à : [C++] Bibliothèque Argstream : arguments de la ligne de commande


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR