Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions parameter/criterion/include/criterion/Criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,6 @@ class Criterion : public IXmlSource, public CriterionInterface
const ValuePairs& derivedValuePairs,
const MatchMethods& derivedMatchMethods);

/** Set a "default formatted state" when no criterion state is set
*
* @param formattedState, the formatted state string to check
* @result the reference of the string passed in parameter filled with the default value
* if it was empty
*
* This method returns a reference on his referenced parameter in order to have the easy
* notation.
* return checkFormattedStateEmptyness(myFormattedStateToReturn);
*/
std::string& checkFormattedStateEmptyness(std::string& formattedState) const;

/** Contains pair association between literal and numerical value */
ValuePairs mValuePairs;

Expand Down
20 changes: 7 additions & 13 deletions parameter/criterion/src/Criterion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ std::string Criterion::getCriterionName() const
std::string Criterion::getFormattedDescription(bool bWithTypeInfo, bool bHumanReadable) const
{
std::string strFormattedDescription;
std::string typeName = isInclusive() ? "Inclusive" : "Exclusive";

if (bHumanReadable) {

Expand All @@ -118,7 +119,7 @@ std::string Criterion::getFormattedDescription(bool bWithTypeInfo, bool bHumanRe

// Type Kind
strFormattedDescription += "(";
strFormattedDescription += isInclusive() ? "Inclusive" : "Exclusive";
strFormattedDescription += typeName;
strFormattedDescription += "): ";

// States
Expand All @@ -140,7 +141,7 @@ std::string Criterion::getFormattedDescription(bool bWithTypeInfo, bool bHumanRe
if (bWithTypeInfo) {
// Type Kind
strFormattedDescription += ", type kind: ";
strFormattedDescription += isInclusive() ? "inclusive" : "exclusive";
strFormattedDescription += typeName;
}

// Current State
Expand Down Expand Up @@ -221,9 +222,10 @@ bool Criterion::getLiteralValue(int numericalValue, std::string& literalValue) c
std::string Criterion::getFormattedState() const
{
std::string formattedState;
getLiteralValue(mState, formattedState);

return Criterion::checkFormattedStateEmptyness(formattedState);
if (!getLiteralValue(mState, formattedState)) {
formattedState = "<none>";
}
return formattedState;
}

std::string Criterion::listPossibleValues() const
Expand All @@ -246,14 +248,6 @@ std::string Criterion::listPossibleValues() const
return possibleValues;
}

std::string& Criterion::checkFormattedStateEmptyness(std::string& formattedState) const
{
if (formattedState.empty()) {
formattedState = "<none>";
}
return formattedState;
}

bool Criterion::match(const std::string& method, int32_t state) const
{
return mMatchMethods.at(method)(state);
Expand Down
10 changes: 8 additions & 2 deletions parameter/criterion/src/InclusiveCriterion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Tokenizer.h"

#include <sstream>
#include <cassert>

namespace core
{
Expand Down Expand Up @@ -92,6 +93,12 @@ bool InclusiveCriterion::getNumericalValue(const std::string& literalValue,
std::string InclusiveCriterion::getFormattedState() const
{
std::string formattedState;
if (mState == 0) {
// Default inclusive criterion state is always present
getLiteralValue(0, formattedState);
return formattedState;
}

uint32_t bit;
bool first = true;

Expand All @@ -117,8 +124,7 @@ std::string InclusiveCriterion::getFormattedState() const

formattedState += atomicState;
}

return Criterion::checkFormattedStateEmptyness(formattedState);
return formattedState;
}

} /** criterion namespace */
Expand Down