Skip to content

Commit

Permalink
cleaned up IndiElement constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredmales committed Dec 20, 2023
1 parent 079a26e commit 7d7c5f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 62 deletions.
4 changes: 2 additions & 2 deletions INDI/INDI/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ next_token ()
/* looks like a constant.
* leading +- already handled
*/
if (nconsts > MAX_OPX) {
if (nconsts >= MAX_OPX) {
(void) sprintf (err_msg, toomc, MAX_OPX);
return (ERR);
}
Expand All @@ -339,7 +339,7 @@ next_token ()
}
} else if (c == '"') {
/* a variable */
if (nvars > MAX_OPX) {
if (nvars >= MAX_OPX) {
(void) sprintf (err_msg, toomv, MAX_OPX);
return (ERR);
}
Expand Down
59 changes: 9 additions & 50 deletions INDI/libcommon/IndiElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,73 +161,32 @@ IndiElement::IndiElement( const string &szName,
m_szValue = string( pcValue );
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a unsigned int value.
/*
IndiElement::IndiElement( const string &szName,
const unsigned int &uiValue )
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
stringstream ssValue;
ssValue << uiValue;
m_szValue = ssValue.str();
}
*/
////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a LightStateType value.

IndiElement::IndiElement( const string &szName,
const LightStateType &tValue )
const LightStateType &tValue ) : m_szFormat("%g"), m_szMax("0"), m_szMin("0"), m_szName(szName), m_szSize("0"),
m_szStep("0"), m_lsValue(tValue), m_ssValue(UnknownSwitchState)
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = tValue;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a SwitchStateType value.

IndiElement::IndiElement( const string &szName,
const SwitchStateType &tValue )
const SwitchStateType &tValue ) : m_szFormat("%g"), m_szMax("0"), m_szMin("0"), m_szName(szName), m_szSize("0"),
m_szStep("0"), m_lsValue(UnknownLightState), m_ssValue(tValue)
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = tValue;
m_szFormat = "%g";
}

////////////////////////////////////////////////////////////////////////////////
/// Copy constructor.

IndiElement::IndiElement( const IndiElement &ieRhs )
{
m_szFormat = ieRhs.m_szFormat;
m_szLabel = ieRhs.m_szLabel;
m_szMax = ieRhs.m_szMax;
m_szMin = ieRhs.m_szMin;
m_szName = ieRhs.m_szName;
m_szSize = ieRhs.m_szSize;
m_szStep = ieRhs.m_szStep;
m_szValue = ieRhs.m_szValue;
m_lsValue = ieRhs.m_lsValue;
m_ssValue = ieRhs.m_ssValue;
IndiElement::IndiElement( const IndiElement &ieRhs ) : m_szFormat(ieRhs.m_szFormat), m_szLabel(ieRhs.m_szLabel),
m_szMax(ieRhs.m_szMax), m_szMin(ieRhs.m_szMin), m_szName(ieRhs.m_szName),
m_szSize(ieRhs.m_szSize), m_szStep(ieRhs.m_szStep), m_szValue(ieRhs.m_szValue),
m_lsValue(ieRhs.m_lsValue), m_ssValue(ieRhs.m_ssValue)
{
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
17 changes: 7 additions & 10 deletions INDI/libcommon/IndiElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,28 @@ class IndiElement
public:
/// Constructor.
IndiElement();

/// Constructor with a name. This will be used often.
IndiElement( const std::string &szName );
/// Constructor with a name and a bool value.
//IndiElement( const std::string &szName, const bool &oValue );
/// Constructor with a name and a double value.
//IndiElement( const std::string &szName, const double &xValue );
/// Constructor with a name and a float value.
//IndiElement( const std::string &szName, const float &eValue );
/// Constructor with a name and an int value.
//IndiElement( const std::string &szName, const int &iValue );

/// Constructor with a name and a string value.
IndiElement( const std::string &szName, const std::string &szValue );

/// Constructor with a name and a char pointer value.
IndiElement( const std::string &szName, const char *pcValue );
/// Constructor with a name and a unsigned int value.
//IndiElement( const std::string &szName, const unsigned int &uiValue );

/// Constructor with a name and a TT value.
template <class TT> IndiElement( const std::string &szName, const TT &tValue );

/// Constructor with a name and a LightStateType value.
IndiElement( const std::string &szName, const LightStateType &tValue );

/// Constructor with a name and a SwitchStateType value.
IndiElement( const std::string &szName, const SwitchStateType &tValue );

/// Copy constructor.
IndiElement( const IndiElement &ieRhs );

/// Destructor.
virtual ~IndiElement();

Expand Down

0 comments on commit 7d7c5f7

Please sign in to comment.