nfd::tools::nfdc::text::ItemAttributes Class Reference

print attributes of an item More...

#include <tools/nfdc/format-helpers.hpp>

+ Inheritance diagram for nfd::tools::nfdc::text::ItemAttributes:
+ Collaboration diagram for nfd::tools::nfdc::text::ItemAttributes:

Classes

struct  Attribute
 

Public Member Functions

 ItemAttributes (bool wantMultiLine=false, int maxAttributeWidth=0)
 constructor More...
 
std::string end () const
 
Attribute operator() (const std::string &attribute)
 

Friends

std::ostream & operator<< (std::ostream &os, const ItemAttributes::Attribute &attr)
 

Detailed Description

print attributes of an item

ItemAttributes ia(wantMultiLine, 3);
os << ia("id") << 500
<< ia("uri") << "udp4://192.0.2.1:6363"
<< ia.end();
// prints in single-line style (wantMultiLine==false):
// id=500 uri=udp4://192.0.2.1:6363 [no-newline]
// prints in multi-line style (wantMultiLine==true):
// id=500
// uri=udp4://192.0.2.1:6363 [newline]

Definition at line 132 of file format-helpers.hpp.

Constructor & Destructor Documentation

nfd::tools::nfdc::text::ItemAttributes::ItemAttributes ( bool  wantMultiLine = false,
int  maxAttributeWidth = 0 
)
explicit

constructor

Parameters
wantMultiLinetrue to select multi-line style, false to use single-line style
maxAttributeWidthmaximum width of attribute names, for alignment in multi-line style

Definition at line 143 of file format-helpers.cpp.

Member Function Documentation

std::string nfd::tools::nfdc::text::ItemAttributes::end ( ) const

Definition at line 157 of file format-helpers.cpp.

ItemAttributes::Attribute nfd::tools::nfdc::text::ItemAttributes::operator() ( const std::string &  attribute)
Note
Caller must ensure ItemAttributes object is alive until after all Attribute objects are destructed.

Definition at line 151 of file format-helpers.cpp.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ItemAttributes::Attribute attr 
)
friend

Definition at line 163 of file format-helpers.cpp.