Minsky
minsky::FlowCoef Struct Reference

represents a numerical coefficient times a variable (a "flow") More...

#include <flowCoef.h>

Collaboration diagram for minsky::FlowCoef:
Collaboration graph

Public Member Functions

 FlowCoef ()
 
 FlowCoef (double coef, const std::string &name)
 
 FlowCoef (const std::string &formula)
 
std::string str () const
 

Public Attributes

double coef
 
std::string name
 

Detailed Description

represents a numerical coefficient times a variable (a "flow")

Definition at line 27 of file flowCoef.h.

Constructor & Destructor Documentation

◆ FlowCoef() [1/3]

minsky::FlowCoef::FlowCoef ( )
inline

Definition at line 31 of file flowCoef.h.

31 : coef(0) {}

◆ FlowCoef() [2/3]

minsky::FlowCoef::FlowCoef ( double  coef,
const std::string &  name 
)
inline

Definition at line 32 of file flowCoef.h.

32 : coef(coef), name(name) {}
std::string name
Definition: flowCoef.h:30

◆ FlowCoef() [3/3]

minsky::FlowCoef::FlowCoef ( const std::string &  formula)

Definition at line 49 of file flowCoef.cc.

References f, anonymous_namespace{flowCoef.cc}::parseLine(), minsky::tail, and minsky::trimWS().

50  {
51  const char* f=formula.c_str();
52  char* tail;
53  std::string prefix;
54 
55  // If NaN or inf appear in any form or case in the name of a flow coefficient, tail is set equal to f. For ticket 1177.
56  if (parseLine(formula, prefix)) {
57  tail=(char*)f;
58  } else coef=strtod(f,&tail);
59 
60  if (tail==f) // oops, that failed, check if there's a leading - sign
61  {
62  // skip whitespace
63  while (*tail != '\0' && isspace(*tail)) ++tail;
64  if (*tail=='\0')
65  {
66  coef=0;
67  return; // empty cell, nothing to do
68  }
69  if (*tail=='-')
70  {
71  coef=-1; // treat leading - sign as -1
72  tail++;
73  }
74  else
75  coef=1;
76  }
77 
78  name=trimWS(tail);
79  }
function f
Definition: canvas.m:1
std::string name
Definition: flowCoef.h:30
bool parseLine(std::string const &line, std::string &pref)
Definition: flowCoef.cc:33
std::string trimWS(const std::string &s)
Definition: str.h:49
Here is the call graph for this function:

Member Function Documentation

◆ str()

string minsky::FlowCoef::str ( ) const

Definition at line 81 of file flowCoef.cc.

References minsky::str().

Referenced by minsky::Minsky::balanceColumns(), minsky::GodleyTableEditor::draw(), schema2::Item::Item(), minsky::GodleyTable::rename(), minsky::GodleyTable::renameFlows(), minsky::GodleyTable::renameStock(), and minsky::GodleyIcon::update().

82  {
83  if (name.empty())
84  return minsky::str(coef);
85  if (coef==1)
86  return name;
87  if (coef==-1)
88  return "-"+name;
89  return minsky::str(coef)+name;
90  }
std::string name
Definition: flowCoef.h:30
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ coef

◆ name


The documentation for this struct was generated from the following files: