void QueryExpression::setQueryContext(QueryContext& inCtx)
{
  if(_ss == NULL){
    MessageLoaderParms parms("Query.QueryExpression.SS_IS_NULL",
                             "Trying to process a query with a NULL SelectStatement.");
    throw QueryException(parms);
  }

  // SelectStatement only allows this to be called once.
  _ss->setQueryContext(inCtx);

#ifndef PEGASUS_DISABLE_CQL
  String cql("CIM:CQL");

  if (_queryLang == cql)
  {
    // Now that we have a QueryContext, we can finish compiling
    // the CQL statement.
    CQLSelectStatement* tempSS = dynamic_cast<CQLSelectStatement*>(_ss);
    if (tempSS != NULL)
    {
      CQLParser::parse(getQuery(), *tempSS);
      tempSS->applyContext();
    }
  }
#endif
}
Exemple #2
0
uint64_t QueryTimeSwapped::getElapsedNanoseconds() const
{
	if( ! mIsStopped ) {
		throw QueryException( "end() must be called before querying the result." );
	}
	const auto& query = mQueryBuffers[mSwapIndex];
	return ( query->isValid() ) ? query->getValueUInt64() : 0;
}
Exemple #3
0
// walks a set of query set tokens through a JSON object graph
// returns the value indicated by the query
Json::Value QueryObject(const Json::Value root,const TokenSet& query){
    int i = 0;
    Json::Value node = root;

    for(std::string term : query){
        if(!node.isObject()){
            throw QueryException("Query node must be an object: ",query,i);
        }
        // query this object to find our path element
        Json::Value next = node[term];
        if(next.isNull()){
            throw QueryException("Failed to find query element: ",query,i);
        }
        node = next;
        i++;
    }
    return node;
}
String QueryExpression::getQuery() const
{
  if(_ss == NULL){
    MessageLoaderParms parms("Query.QueryExpression.SS_IS_NULL",
                             "Trying to process a query with a NULL SelectStatement.");
    throw QueryException(parms);
  }

  return _ss->getQuery();
}
void SelectStatementRep::setQueryContext(QueryContext& inCtx)
{
  if (_ctx == NULL)
  {
    _ctx = inCtx.clone();
  }
  else
  {
    throw QueryException(MessageLoaderParms("QueryCommon.SelectStatementRep.QUERY_CTX_ALREADY_SET",
                        "The QueryContext can only be set once on a SelectStatement."));
  }
}
int PrimaryTree::search(Node *node, std::string string) const{

	if (node == 0) {
		throw QueryException();
	} else if (string > node->key) {
		return search(node->right, string);
	} else if (string < node->key) {
		return search(node->left, string);
	} else {
		return node->manpage_index;
	}
}
Array<CIMObjectPath> QueryExpression::getClassPathList() const{
  if(_ss == NULL){
    MessageLoaderParms parms("Query.QueryExpression.SS_IS_NULL",
                             "Trying to process a query with a NULL SelectStatement.");
    throw QueryException(parms);
  }

  try
  {
   return _ss->getClassPathList();
  }
  catch (QueryException&)
  {
    throw;
  }
  catch (Exception& e)
  {
    throw PEGASUS_QUERY_EXCEPTION(e.getContentLanguages(), e.getMessage());
  }
}
void QueryExpression::validate(){
  if(_ss == NULL){
    MessageLoaderParms parms("Query.QueryExpression.SS_IS_NULL",
                             "Trying to process a query with a NULL SelectStatement.");
    throw QueryException(parms);
  }

  try
  {
    _ss->validate();
  }
  catch (QueryException&)
  {
    throw;
  }
  catch (Exception& e)
  {
    throw PEGASUS_QUERY_EXCEPTION(e.getContentLanguages(), e.getMessage());
  }
}
Boolean QueryExpression::evaluate(const CIMInstance & inst) const
{
  if(_ss == NULL){
    MessageLoaderParms parms("Query.QueryExpression.SS_IS_NULL",
                             "Trying to process a query with a NULL SelectStatement.");
    throw QueryException(parms);
  }

  try
  {
    return _ss->evaluate(inst);
  }
  catch (QueryException&)
  {
    throw;
  }
  catch (Exception& e)
  {
    throw PEGASUS_QUERY_EXCEPTION(e.getContentLanguages(), e.getMessage());
  }
}
void QueryExpression::applyProjection(CIMInstance instance,
    Boolean allowMissing)
{
  if(_ss == NULL){
    MessageLoaderParms parms("Query.QueryExpression.SS_IS_NULL",
                             "Trying to process a query with a NULL SelectStatement.");
    throw QueryException(parms);
  }

  try
  {
    _ss->applyProjection(instance, allowMissing);
  }
  catch (QueryException&)
  {
    throw;
  }
  catch (Exception& e)
  {
    throw PEGASUS_QUERY_EXCEPTION(e.getContentLanguages(), e.getMessage());
  }
}