Public Member Functions | Private Attributes | Friends | List of all members
PLMD::Citations Class Reference

#include <Citations.h>

Public Member Functions

std::string cite (const std::string &)
 Add a citation. More...
 
void clear ()
 Delete all references. More...
 
bool empty () const
 Check if bibliography is empty. More...
 

Private Attributes

std::vector< std::string > items
 

Friends

std::ostream & operator<< (std::ostream &, const Citations &)
 Dumps the bibliography. More...
 

Detailed Description

Class taking care of bibliography.

This class contains a vector of citations. To add a new citations, use cite(). To print the entire bibliography, just dump on a ostream. Everytime cite is used, a string containing the number of the citation is returned. If the same citation is added twice, the same string is returned, so that this example will produce only two bibliographic items:

#include "Citations.h"
#include <iostream>
int main(int argc,char**argv){
  PLMD::Citations citations;
  std::cout << citations.cite("Pinco e Pallino, Il Piccolo 33, 444 (2012)") << "\n";
  std::cout << citations.cite("Other cite") << "\n";
  std::cout << citations.cite("Pinco e Pallino, Il Piccolo 33, 444 (2012)") << "\n";

  std::cout << "Bibliography\n"<< citations;
  return 0;
}

Member Function Documentation

◆ cite()

std::string PLMD::Citations::cite ( const std::string &  item)

Add a citation.

It returns a string containing the reference number, something like "[10]"

◆ clear()

void PLMD::Citations::clear ( )

Delete all references.

◆ empty()

bool PLMD::Citations::empty ( ) const

Check if bibliography is empty.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const Citations  
)
friend

Dumps the bibliography.

It writes on the ostream the list of all the bibliographic items prefixed with their reference number

Member Data Documentation

◆ items

std::vector<std::string> PLMD::Citations::items
private

The documentation for this class was generated from the following files: