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]
ItemAttributes(bool wantMultiLine=false, int maxAttributeWidth=0)
Constructor.

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

Constructor & Destructor Documentation

◆ ItemAttributes()

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 149 of file format-helpers.cpp.

Member Function Documentation

◆ end()

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

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

◆ operator()()

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 156 of file format-helpers.cpp.

Friends And Related Function Documentation

◆ operator<<

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

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