Skip to content

Commit

Permalink
Add preferred-markers to supported-printout
Browse files Browse the repository at this point in the history
  • Loading branch information
attah committed Mar 1, 2024
1 parent 11ee03a commit fbffb7f
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions lib/setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,44 @@ class PreferredChoiceSetting : public ChoiceSetting<T>

List<T> getPreferred() const
{
IppAttrs* pa = this->_printerAttrs;
return pa->getList<T>(this->_name+"-"+_pref);
List<T> preferred;
if(this->_printerAttrs->has(this->_name+"-"+_pref))
{
IppAttrs* pa = this->_printerAttrs;
preferred = pa->getList<T>(this->_name+"-"+_pref);
}
return preferred;
}

virtual std::string supportedStr()
{
if(this->_printerAttrs->has(this->_name+"-supported"))
{
std::stringstream ss;
IppOneSetOf supported = this->_printerAttrs->at(this->_name+"-supported").asList();
IppOneSetOf preferred;
if(this->_printerAttrs->has(this->_name+"-"+_pref))
{
preferred = this->_printerAttrs->at(this->_name+"-"+_pref).asList();
}
for(IppOneSetOf::const_iterator it = supported.cbegin(); it != supported.cend(); it++)
{
ss << *it;
if(preferred.contains(*it))
{
ss << "(" << _pref << ")";
}
if(std::next(it) != supported.end())
{
ss << ", ";
}
}
return ss.str();
}
else
{
return "unsupported";
}
}

private:
Expand Down

0 comments on commit fbffb7f

Please sign in to comment.