Пример #1
0
CDataArray::name_index_type CDataArray::displayNamesToCN(const std::vector< std::string > & DisplayNames) const
{
  assert(DisplayNames.size() == dimensionality()
         || dimensionality() == 0);

  name_index_type CNIndex(dimensionality());
  name_index_type::iterator to = CNIndex.begin();
  std::vector< std::string >::const_iterator it = DisplayNames.begin();
  std::vector< std::string >::const_iterator end = DisplayNames.end();
  std::vector< std::vector<CRegisteredCommonName> >::const_iterator itCNs = mAnnotationsCN.begin();
  size_t dimension = 0;

  for (; it != end && dimension < dimensionality(); ++it, ++itCNs, ++dimension, ++to)
    {
      std::vector<CRegisteredCommonName>::const_iterator itCN = itCNs->begin();
      std::vector<CRegisteredCommonName>::const_iterator endCN = itCNs->end();

      for (; itCN != endCN; ++itCN)
        {
          if (CCommonName::unescape(*it) == createDisplayName(*itCN))
            {
              *to = *itCN;
              break;
            }
        }

      if (itCN == endCN)
        {
          size_t index = C_INVALID_INDEX;
          bool ValidIndex = strToIndex(*it, index);

          if (ValidIndex)
            {
              if (itCNs->empty())
                {
                  *to = *it;
                }
              else
                {
                  *to = itCNs->operator [](index);
                }
            }
          else
            {
              *to = std::string("not found");
            }
        }
    }

  return CNIndex;
}
Пример #2
0
const CCopasiObject * CArrayAnnotation::addElementReference(C_INT32 u) const
{
  CArrayAnnotation::name_index_type CNIndex(1);

  if ((C_INT32)mAnnotationsCN[0].size() <= u &&
      (C_INT32)mpArray->size()[0] >= u)
    {
      const_cast< CArrayAnnotation * >(this)->autoAnnotation(0);
    }

  CNIndex[0] = mAnnotationsCN[0][u];

  return addElementReference(CNIndex);
}
Пример #3
0
const CCopasiObject * CArrayAnnotation::addElementReference(const CArrayAnnotation::index_type & index) const
{
  CArrayAnnotation::name_index_type CNIndex(index.size());

  CArrayAnnotation::index_type::const_iterator it = index.begin();
  CArrayAnnotation::index_type::const_iterator end = index.end();
  std::vector< std::vector<CRegisteredObjectName> >::const_iterator itCN = mAnnotationsCN.begin();
  CArrayAnnotation::name_index_type::iterator to = CNIndex.begin();

  for (; it != end; ++it, ++itCN, ++to)
    {
      *to = itCN->operator [](*it);
    }

  return addElementReference(CNIndex);
}
Пример #4
0
CArrayAnnotation::name_index_type CArrayAnnotation::displayNamesToCN(const std::vector< std::string > & DisplayNames) const
{
  assert(DisplayNames.size() == dimensionality()
         || dimensionality() == 0);

  name_index_type CNIndex(dimensionality());
  name_index_type::iterator to = CNIndex.begin();
  std::vector< std::string >::const_iterator it = DisplayNames.begin();
  std::vector< std::string >::const_iterator end = DisplayNames.end();
  std::vector< std::vector<CRegisteredObjectName> >::const_iterator itCNs = mAnnotationsCN.begin();
  size_t index = 0;

  for (; it != end && index < dimensionality(); ++it, ++itCNs, ++index, ++to)
    {
      std::vector<CRegisteredObjectName>::const_iterator itCN = itCNs->begin();
      std::vector<CRegisteredObjectName>::const_iterator endCN = itCNs->end();

      for (; itCN != endCN; ++itCN)
        {
          if (*it == this->createDisplayName(*itCN))
            {
              *to = *itCN;
              break;
            }
        }

      if (itCN == endCN)
        {
          const char * pTail = NULL;

          C_INT32 index = strToInt(it->c_str(), &pTail);

          if (itCNs->empty() || pTail != it->c_str() + it->size())
            {
              *to = std::string("not found");
            }
          else
            {
              *to = itCNs->operator [](index);
            }
        }
    }

  return CNIndex;
}
Пример #5
0
const CDataObject * CDataArray::addElementReference(const CDataArray::index_type & index) const
{
  CDataArray::name_index_type CNIndex(index.size());
  CDataArray::name_index_type::iterator to = CNIndex.begin();
  CDataArray::index_type::const_iterator it = index.begin();
  CDataArray::index_type::const_iterator end = index.end();
  std::vector< std::vector<CRegisteredCommonName> >::const_iterator itCN = mAnnotationsCN.begin();

  for (; it != end; ++it, ++to, ++itCN)
    {
      *to = *it < itCN->size() ? itCN->operator [](*it) : CRegisteredCommonName("");

      if (to->empty())
        {
          *to = StringPrint("%d", *it);
        }
    }

  return addElementReference(CNIndex);
}