当前位置: 首页>>代码示例>>C++>>正文


C++ DataException函数代码示例

本文整理汇总了C++中DataException函数的典型用法代码示例。如果您正苦于以下问题:C++ DataException函数的具体用法?C++ DataException怎么用?C++ DataException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DataException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

DECLARE_EXPORT SetupMatrix::Rule* SetupMatrix::createRule(const AttributeList& atts)
{
  // Pick up the start, end and name attributes
  int priority = atts.get(Tags::tag_priority)->getInt();

  // Check for existence of a rule with the same priority
  Rule* result = firstRule;
  while (result && priority > result->priority)
    result = result->nextRule;
  if (result && result->priority != priority) result = NULL;

  // Pick up the action attribute and update the rule accordingly
  switch (MetaClass::decodeAction(atts))
  {
    case ADD:
      // Only additions are allowed
      if (result)
      {
        ostringstream o;
        o << "Rule with priority "  << priority
          << " already exists in setup matrix '" << getName() << "'";
        throw DataException(o.str());
      }
      result = new Rule(this, priority);
      return result;
    case CHANGE:
      // Only changes are allowed
      if (!result)
      {
        ostringstream o;
        o << "No rule with priority " << priority
          << " exists in setup matrix '" << getName() << "'";
        throw DataException(o.str());
      }
      return result;
    case REMOVE:
      // Delete the entity
      if (!result)
      {
        ostringstream o;
        o << "No rule with priority " << priority
          << " exists in setup matrix '" << getName() << "'";
        throw DataException(o.str());
      }
      else
      {
        // Delete it
        delete result;
        return NULL;
      }
    case ADD_CHANGE:
      if (!result)
        // Adding a new rule
        result = new Rule(this, priority);
      return result;
  }

  // This part of the code isn't expected not be reached
  throw LogicException("Unreachable code reached");
}
开发者ID:ConePerez,项目名称:frePPLe,代码行数:60,代码来源:setupmatrix.cpp

示例2: cost

DECLARE_EXPORT SetupMatrix::Rule::Rule(SetupMatrix *s, int p)
  : cost(0), priority(p), matrix(s), nextRule(NULL), prevRule(NULL)
{
  // Validate the arguments
  if (!matrix) throw DataException("Can't add a rule to NULL setup matrix");

  // Find the right place in the list
  Rule *next = matrix->firstRule, *prev = NULL;
  while (next && p > next->priority)
  {
    prev = next;
    next = next->nextRule;
  }

  // Duplicate priority
  if (next && next->priority == p)
    throw DataException("Multiple rules with identical priority in setup matrix");

  // Maintain linked list
  nextRule = next;
  prevRule = prev;
  if (prev) prev->nextRule = this;
  else matrix->firstRule = this;
  if (next) next->prevRule = this;

  // Initialize the Python type
  initType(metadata);
}
开发者ID:ConePerez,项目名称:frePPLe,代码行数:28,代码来源:setupmatrix.cpp

示例3: getNumSamples

int
FunctionSpace::getTagFromDataPointNo(DataTypes::dim_t dataPointNo) const
{
  //
  // Get the number of samples and data-points per sample
  int numSamples = getNumSamples();
  int numDataPointsPerSample = getNumDPPSample();
  int numDataPoints = numSamples * numDataPointsPerSample;

  if (numDataPointsPerSample==0) {
    throw DataException("FunctionSpace::getTagFromDataPointNo error: no data-points associated with this object.");
  }

  if (dataPointNo<0 || dataPointNo>=numDataPoints) {
    throw DataException("FunctionSpace::getTagFromDataPointNo error: invalid data-point number supplied.");
  }

  //
  // Determine the sample number which corresponds to this data-point number
  int sampleNo = dataPointNo / numDataPointsPerSample;

  //
  // Determine the tag number which corresponds to this sample number
  int tagNo = getTagFromSampleNo(sampleNo);

  //
  // return the tag number
  return(tagNo);
}
开发者ID:svn2github,项目名称:Escript,代码行数:29,代码来源:FunctionSpace.cpp

示例4: PyDict_GetItemString

PyObject* SubOperation::create(PyTypeObject* pytype, PyObject* args, PyObject* kwds)
{
  try
  {
    // Pick up the operation
    PyObject* oper = PyDict_GetItemString(kwds, "operation");
    if (!oper)
      throw DataException("Missing operation on SubOperation");
    if (!PyObject_TypeCheck(oper, Operation::metadata->pythonClass))
      throw DataException("field 'operation' of suboperation must be of type operation");

    // Pick up the owner
    PyObject* owner = PyDict_GetItemString(kwds, "owner");
    if (!owner)
      throw DataException("Missing owner on SubOperation");
    if (!PyObject_TypeCheck(owner, Operation::metadata->pythonClass))
      throw DataException("field 'operation' of suboperation must be of type operation");

    // Pick up the type and create the suboperation
    SubOperation *l = new SubOperation();
    if (oper) l->setOperation(static_cast<Operation*>(oper));
    if (owner) l->setOwner(static_cast<Operation*>(owner));

    // Iterate over extra keywords, and set attributes.   @todo move this responsibility to the readers...
    if (l)
    {
      PyObject *key, *value;
      Py_ssize_t pos = 0;
      while (PyDict_Next(kwds, &pos, &key, &value))
      {
        PythonData field(value);
        PyObject* key_utf8 = PyUnicode_AsUTF8String(key);
        DataKeyword attr(PyBytes_AsString(key_utf8));
        Py_DECREF(key_utf8);
        if (!attr.isA(Tags::operation) && !attr.isA(Tags::owner)
           && !attr.isA(Tags::type) && !attr.isA(Tags::action))
        {
          const MetaFieldBase* fmeta = SubOperation::metacategory->findField(attr.getHash());
          if (fmeta)
            // Update the attribute
            fmeta->setField(l, field);
          else
            l->setProperty(attr.getName(), value);
        }
      };
    }

    // Return the object
    Py_INCREF(l);
    return static_cast<PyObject*>(l);
  }
  catch (...)
  {
    PythonType::evalException();
    return nullptr;
  }
}
开发者ID:frePPLe,项目名称:frePPLe,代码行数:57,代码来源:suboperation.cpp

示例5: PyDict_GetItemString

/** @todo this method implementation is not generic enough and not extendible by subclasses. */
PyObject* ResourceSkill::create(PyTypeObject* pytype, PyObject* args, PyObject* kwds)
{
  try
  {
    // Pick up the skill
    PyObject* skill = PyDict_GetItemString(kwds,"skill");
    if (!PyObject_TypeCheck(skill, Skill::metadata->pythonClass))
      throw DataException("resourceskill skill must be of type skill");

    // Pick up the resource
    PyObject* res = PyDict_GetItemString(kwds,"resource");
    if (!PyObject_TypeCheck(res, Resource::metadata->pythonClass))
      throw DataException("resourceskill resource must be of type resource");

    // Pick up the priority
    PyObject* q1 = PyDict_GetItemString(kwds,"priority");
    int q2 = q1 ? PythonObject(q1).getInt() : 1;

    // Pick up the effective dates
    DateRange eff;
    PyObject* eff_start = PyDict_GetItemString(kwds,"effective_start");
    if (eff_start)
    {
      PythonObject d(eff_start);
      eff.setStart(d.getDate());
    }
    PyObject* eff_end = PyDict_GetItemString(kwds,"effective_end");
    if (eff_end)
    {
      PythonObject d(eff_end);
      eff.setEnd(d.getDate());
    }

    // Create the load
    ResourceSkill *l = new ResourceSkill(
      static_cast<Skill*>(skill),
      static_cast<Resource*>(res),
      q2, eff
    );

    // Return the object
    Py_INCREF(l);
    return static_cast<PyObject*>(l);
  }
  catch (...)
  {
    PythonType::evalException();
    return NULL;
  }
}
开发者ID:albertca,项目名称:frePPLe,代码行数:51,代码来源:resourceskill.cpp

示例6: BindIntVariables

void  BindIntVariables(DBHandles *d, DataFeedData *df)
{
    SQLRETURN r;

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_TIMESTAMP, 19, 0, df->timestamp, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->highPrice, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->lowPrice, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->openPrice, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->closePrice, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, -5, 8, 0, df->totalVol, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_INTEGER, 4, 0, df->vol, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (o.isOption == true || o.isFutures == true || o.useContract == true) {
        if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 10, 0, (SQLPOINTER) df->symbol, (SQLINTEGER) strlen(df->symbol), &df->stringLength)))
            throw DataException(__FILE__, __LINE__);
    }
}
开发者ID:steve8918,项目名称:iqdata,代码行数:30,代码来源:main.cpp

示例7: readXMLdata

DECLARE_EXPORT PyObject* readXMLdata(PyObject *self, PyObject *args)
{
  // Pick up arguments
  char *data;
  int validate(1), validate_only(0);
  PyObject *userexit = NULL;
  int ok = PyArg_ParseTuple(args, "s|iiO:readXMLdata",
    &data, &validate, &validate_only, &userexit);
  if (!ok) return NULL;

  // Free Python interpreter for other threads
  Py_BEGIN_ALLOW_THREADS

  // Execute and catch exceptions
  try
  {
    if (!data) throw DataException("No input data");
    XMLInputString p(data);
    if (userexit) p.setUserExit(userexit);
    if (validate_only!=0)
      p.parse(NULL, true);
    else
      p.parse(&Plan::instance(), validate!=0);
  }
  catch (...)
  {
    Py_BLOCK_THREADS;
    PythonType::evalException();
    return NULL;
  }
  Py_END_ALLOW_THREADS   // Reclaim Python interpreter
  return Py_BuildValue("");  // Safer than using Py_None, which is not portable across compilers
}
开发者ID:ConePerez,项目名称:frePPLe,代码行数:33,代码来源:actions.cpp

示例8: DataException

DECLARE_EXPORT void Resource::setMaximum(double m)
{
  if (m < 0)
    throw DataException("Maximum capacity for resource '" + getName() + "' must be postive");

  // There is already a maximum calendar.
  if (size_max_cal)
  {
    // We update the field, but don't use it yet.
    size_max = m;
    return;
  }

  // Mark as changed
  setChanged();

  // Set field
  size_max = m;

  // Create or update a single timeline max event
  for (loadplanlist::iterator oo=loadplans.begin(); oo!=loadplans.end(); oo++)
    if (oo->getType() == 4)
    {
      // Update existing event
      static_cast<loadplanlist::EventMaxQuantity *>(&*oo)->setMax(size_max);
      return;
    }
  // Create new event
  loadplanlist::EventMaxQuantity *newEvent =
    new loadplanlist::EventMaxQuantity(Date::infinitePast, &loadplans, size_max);
  loadplans.insert(newEvent);
}
开发者ID:zhoufoxcn,项目名称:frePPLe,代码行数:32,代码来源:resource.cpp

示例9: WriteDataToDB

int WriteDataToDB(DBHandles *d, DataFeedData *df)
{
    SQLINTEGER stringLength = SQL_NTS;
    SQLRETURN r;

    //only daily data need this, because the times are jacked up so
    //I just manually set it to midnight
    if (o.useDaily == true)
    {
        char newTransactionTime[50];
        char dummy[50];
        sscanf(df->timestamp, "%s %s", newTransactionTime, dummy);
        sprintf(df->timestamp, "%s 00:00:00", newTransactionTime);
    }

    r = SQLExecute(d->hstmt);

    if (!SQL_SUCCEEDED(r))
    {
        std::string errorString;
        int errorNum = ODBCError(d, errorString);
        //error code denoting that the row already exists
        if (errorNum == 2601 || errorNum == 2627)
            return 0;
        else
            throw DataException(__FILE__, __LINE__);
    }

    return 1;
}
开发者ID:steve8918,项目名称:iqdata,代码行数:30,代码来源:main.cpp

示例10: DataException

void SubOperation::setOwner(Operation* o)
{
  if (o == owner)
    // No change
    return;

  if (o && !o->hasSubOperations())
    // Some operation types don't have suboperations
    throw DataException("Operation '" + o->getName() + "' can't have suboperations");

  // Remove from previous owner
  if (oper && owner)
    oper->removeSuperOperation(owner);
  if (owner)
    owner->getSubOperations().remove(this);

  // Update
  owner = o;

  // Insert at new owner
  if (oper && owner)
    oper->addSuperOperation(owner);
  if (owner)
  {
    Operation::Operationlist::iterator iter = owner->getSubOperations().begin();
    while (iter != owner->getSubOperations().end() && prio >= (*iter)->getPriority())
      ++iter;
    owner->getSubOperations().insert(iter, this);
  }
}
开发者ID:frePPLe,项目名称:frePPLe,代码行数:30,代码来源:suboperation.cpp

示例11: saveXMLfile

PyObject* saveXMLfile(PyObject* self, PyObject* args)
{
  // Pick up arguments
  char *filename;
  char *content = NULL;
  int ok = PyArg_ParseTuple(args, "s|s:save", &filename, &content);
  if (!ok) return NULL;

  // Execute and catch exceptions
  Py_BEGIN_ALLOW_THREADS   // Free Python interpreter for other threads
  try
  {
    XMLOutputFile o(filename);
    if (content)
    {
      if (!strcmp(content,"STANDARD"))
        o.setContentType(XMLOutput::STANDARD);
      else if (!strcmp(content,"PLAN"))
        o.setContentType(XMLOutput::PLAN);
      else if (!strcmp(content,"PLANDETAIL"))
        o.setContentType(XMLOutput::PLANDETAIL);
      else
        throw DataException("Invalid content type '" + string(content) + "'");
    }
    o.writeElementWithHeader(Tags::tag_plan, &Plan::instance());
  }
  catch (...)
  {
    Py_BLOCK_THREADS;
    PythonType::evalException();
    return NULL;
  }
  Py_END_ALLOW_THREADS   // Reclaim Python interpreter
  return Py_BuildValue("");
}
开发者ID:ConePerez,项目名称:frePPLe,代码行数:35,代码来源:actions.cpp

示例12: while

DECLARE_EXPORT void Calendar::removeBucket(CalendarBucket* bkt)
{
  // Verify the bucket is on this calendar indeed
  CalendarBucket *b = firstBucket;
  while (b && b != bkt) b = b->nextBucket;

  // Error
  if (!b)
    throw DataException("Trying to remove unavailable bucket from calendar '"
        + getName() + "'");

  // Update the list
  if (bkt->prevBucket)
    // Previous bucket links to a new next bucket
    bkt->prevBucket->nextBucket = bkt->nextBucket;
  else
    // New head for the bucket list
    firstBucket = bkt->nextBucket;
  if (bkt->nextBucket)
    // Update the reference prevBucket of the next bucket
    bkt->nextBucket->prevBucket = bkt->prevBucket;

  // Delete the bucket
  delete bkt;
}
开发者ID:ElevimRG,项目名称:frePPLe,代码行数:25,代码来源:calendar.cpp

示例13: sub_path

QString Customizations::DataBasePath()
{
	static bool cached = false;
	if ( cached )
		return dataBasePath_;

	QList<QString> checked_paths;
	QString sub_path( "lobby/SpringLobby/customizations/" );
	sub_path.append( m_shortname );
	for ( int i = 0; i < susynclib().GetSpringDataDirCount(); ++i ) {
		QDir data ( ToQString( susynclib().GetSpringDataDirByIndex(i) ) );
		checked_paths.append( data.absolutePath().append("/").append( sub_path ) );
		if ( data.cd( sub_path ) ) {
			dataBasePath_ = data.absolutePath();
			break;
		}
	}
	if( dataBasePath_ != QString() )
		return dataBasePath_ ;

	checked_paths.prepend( QString("Couldn't find customization data in any of these directories:\n ") );
	throw DataException( checked_paths );

	return QString();
}
开发者ID:hoijui,项目名称:springlobby,代码行数:25,代码来源:customizations.cpp

示例14: WriteOneLine

int WriteOneLine(DBHandles *d, char *oneLine, boost::unordered_set<dataPoint> *hash, DataFeedData *df)
{
    if (o.useTicks == true)
    {
        ExtractTickData(oneLine, df);

        //first check the hashTable to see if it already has the data
        if (o.useHashTable == true && hash != NULL)
        {
            dataPoint dp;
            dp.date = GetUDate(df->timestamp, dateGC);
            dp.tickId = atoi(df->tickId);

            if (hash->find(dp) != hash->end())
                return 0;
        }
    }
    else if (o.useInterval == true || o.useDaily == true)
    {
        ExtractIntData(oneLine, df);
    }
    else
    {
        WriteLog("Missing useInterval or useTicks\n");
        throw DataException(__FILE__, __LINE__);
    }

    return WriteDataToDB(d, df);
}
开发者ID:steve8918,项目名称:iqdata,代码行数:29,代码来源:main.cpp

示例15: DataException

DECLARE_EXPORT void Load::setAlternate(Load *f)
{
  // Can't be an alternate to oneself.
  // No need to flag as an exception.
  if (f == this) return;

  // Validate the argument
  if (!f)
    throw DataException("Setting NULL alternate load");
  if (hasAlts || f->altLoad)
    throw DataException("Nested alternate loads are not allowed");

  // Update both flows
  f->hasAlts = true;
  altLoad = f;
}
开发者ID:zhoufoxcn,项目名称:frePPLe,代码行数:16,代码来源:load.cpp


注:本文中的DataException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。