コード例 #1
0
bool ImplicitTagRulesDatabaseDeriver::_wordIsNotASchemaTagValue(const QString word)
{
  //If _useSchemaTagValuesForWordsOnly is activated, the word is not on the ignore list, and any
  //token in the name matches a OSM tag value parsed from the hoot schema, then the whole word is
  //eligible for implicit tag extraction.

  StringTokenizer tokenizer;
  bool wordNotASchemaTagValue = false;
  if (_useSchemaTagValuesForWordsOnly && !word.trimmed().isEmpty() &&
      !_customRules.getWordIgnoreList().contains(word, Qt::CaseInsensitive))
  {
    wordNotASchemaTagValue = true;
    const QStringList tokenizedWords = tokenizer.tokenize(word.toLower());
    for (int i = 0; i < tokenizedWords.size(); i++)
    {
      const QString tokenizedWord = tokenizedWords.at(i);
      if (_schemaTagValues.contains(tokenizedWord) &&
          !_customRules.getWordIgnoreList().contains(tokenizedWord, Qt::CaseInsensitive))
      {
        wordNotASchemaTagValue = false;
        break;
      }
    }
  }
  return wordNotASchemaTagValue;
}
コード例 #2
0
std::string
NIImporter_DlrNavteq::EdgesHandler::getColumn(const StringTokenizer& st, ColumnName name, const std::string fallback) {
    assert(!myColumns.empty());
    if (myColumns[name] == MISSING_COLUMN) {
        if (fallback == "") {
            throw ProcessError("Missing column " + toString(name) + ".");
        } else {
            return fallback;
        }
    } else if (myColumns[name] >= 0) {
        return st.get((int)(myColumns[name]));
    } else {
        // negative column number implies an optional column
        if ((int) st.size() <= -myColumns[name]) {
            // the column is not present
            if (fallback == "") {
                throw ProcessError("Missing optional column " + toString(name) + " without default value.");
            } else {
                return fallback;
            }
        } else {
            return st.get((int)(-myColumns[name]));
        }
    }
}
コード例 #3
0
/*!

\brief Creates a directory.
\details Defined in dmzSystemFile.h. Function will create a path as deep as is
requested in \a Path. Function returns dmz::True if path already exists.
\param[in] Path String containing directory to create.
\return Returns dmz::True if directory was successfully created.

*/
dmz::Boolean
dmz::create_directory (const String &Path) {

   Boolean result (False);

   if (Path) {

      result = True;
      const String FormattedPath (format_path (Path));
      StringTokenizer st (FormattedPath, '/');
      String dir;
      if (FormattedPath.get_char (0) == '/') { dir << "/"; }
      String part (st.get_next ());

      while (part) {

         if (dir) { dir << "/" << part; }
         else { dir = part; }

         if (!is_valid_path (dir)) {

            if (mkdir (dir.get_buffer (), S_IRUSR | S_IWUSR | S_IXUSR) != 0) {

               result = False;
            }
         }

         if (result) { part = st.get_next (); }
         else { part.flush (); }
      }
   }

   return result;
}
コード例 #4
0
ファイル: dmzRuntimeInit.cpp プロジェクト: ben-sangster/dmz
/*!

\brief Looks up states from names.
\param[in] Name String containing state names.
\param[out] state Mask object to store found states.
\return Returns dmz::True if all named states are found.
\note State names should be delineated by the "|" character (a.k.a. the bitwise or
operator).

*/
dmz::Boolean
dmz::Definitions::lookup_state (const String &Name, Mask &state) const {

   Boolean result (False);

   if (_state.defs) {

      StringTokenizer st (Name, '|');
      String value = st.get_next ();

      result = value;

      while (value) {

         trim_ascii_white_space (value);
         convert_ascii_white_space (value);

         Mask *ptr (_state.defs->maskTable.lookup (value));

         if (ptr) { state |= *ptr; }
         else if (_state.log) {

            _state.log->error << "Unable to find state: " << value
               << " in state name: " << Name << endl;

            result = False;
         }

         value = st.get_next ();
      }
   }

   return result;
}
コード例 #5
0
ファイル: ChildSession.cpp プロジェクト: biostone/online
bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    if (tokens.count() == 1)
    {
        sendTextFrame("error: cmd=uno kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
    const bool bNotify = (tokens[1] == ".uno:Save");

    if (tokens.count() == 2)
    {
        _loKitDocument->postUnoCommand(tokens[1].c_str(), nullptr, bNotify);
    }
    else
    {
        _loKitDocument->postUnoCommand(tokens[1].c_str(),
                                               Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(),
                                               bNotify);
    }

    return true;
}
コード例 #6
0
int QueryQualifierBuilder::setArgument (QueryQualifierBuilder &qualifierBuilder, const char *pszPropertyAndValue)
{
    if (pszPropertyAndValue == NULL) {
        return -1;
    }
    static StringTokenizer tokenizer;
    tokenizer.init (pszPropertyAndValue, '=', '=');
    
    const char *pszProperty = tokenizer.getNextToken();
    if (pszProperty == NULL) {
        return -2;
    }

    String value = tokenizer.getNextToken();
    if (value.length() <= 0) {
        return -3;
    }

    value.trim();

    if (stricmp (GROUP_BY.c_str(), pszProperty) == 0) {
        qualifierBuilder._groupBy = value.c_str();
    }
    else if (stricmp (LIMIT.c_str(), pszProperty) == 0) {
        qualifierBuilder._limit = value.c_str();
    }
    else if (stricmp (ORDER.c_str(), pszProperty) == 0) {
        qualifierBuilder._order = value.c_str();
    }
    else {
        return -4;
    }

    return 0;
}
コード例 #7
0
ファイル: ClientSession.cpp プロジェクト: expansio/online
bool ClientSession::sendFontRendering(const char *buffer, int length, StringTokenizer& tokens)
{
    std::string font;
    if (tokens.count() < 2 ||
        !getTokenString(tokens[1], "font", font))
    {
        return sendTextFrame("error: cmd=renderfont kind=syntax");
    }

    const std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";

    std::vector<char> output;
    output.resize(response.size());
    std::memcpy(output.data(), response.data(), response.size());

    std::unique_ptr<std::fstream> cachedRendering = _docBroker->tileCache().lookupRendering(font, "font");
    if (cachedRendering && cachedRendering->is_open())
    {
        cachedRendering->seekg(0, std::ios_base::end);
        size_t pos = output.size();
        std::streamsize size = cachedRendering->tellg();
        output.resize(pos + size);
        cachedRendering->seekg(0, std::ios_base::beg);
        cachedRendering->read(output.data() + pos, size);
        cachedRendering->close();

        return sendBinaryFrame(output.data(), output.size());
    }

    return forwardToPeer(_peer, buffer, length);
}
コード例 #8
0
bool ChildProcessSession::unoCommand(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    if (tokens.count() == 1)
    {
        sendTextFrame("error: cmd=uno kind=syntax");
        return false;
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);

    // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
    bool bNotify = (tokens[1] == ".uno:Save");

    if (tokens.count() == 2)
    {
        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), 0, bNotify);
    }
    else
    {
        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(), bNotify);
    }

    return true;
}
コード例 #9
0
ファイル: DSProUtils.cpp プロジェクト: fpoltronieri/nomads
 void parsePeers (const char *pszPeerAddresses, StringHashset &addresses)
 {
     StringTokenizer tokenizer (pszPeerAddresses, ';', ';');
     const char *pszRemoteAddress;
     while ((pszRemoteAddress = tokenizer.getNextToken()) != NULL) {
         addresses.put (pszRemoteAddress);
     }
 }
コード例 #10
0
void loadGraph(std::string edgeFile)
{
	// Open file for reading
	freopen(edgeFile.c_str(), "rt", stdin);

	edge_count = 0;
	vecEdges.clear();
	maxNode = -1;

	// Read line by line edge info
	while(gets(buff))
	{
		if(strlen(buff) == 0)
			break;
		edge_count++;

		StringTokenizer token;
		// tokenize using comma
		token.parse(buff, ",");
		std::vector<std::string> vecToken;
		vecToken.clear();
		token.getTokens(vecToken);

		// There should be exactly 9 values: edge_id, start_node_id, end_node_id, 
		// start_node_longitude, start_node_latitude, end_node_longitude, end_node_latitude, cost, reverse_cost
		if(vecToken.size() < 5)
			fprintf(stderr, "Error in %d edge\n", edge_count);

		// Populate Edge_t structure
		edge_astar_t tempEdge;
		tempEdge.id = atoi(vecToken[0].c_str());
		tempEdge.source = atoi(vecToken[1].c_str());
		tempEdge.target = atoi(vecToken[2].c_str());
		tempEdge.cost = atof(vecToken[3].c_str());
		tempEdge.reverse_cost = atof(vecToken[4].c_str());
		tempEdge.s_x = atof(vecToken[5].c_str());
		tempEdge.s_y = atof(vecToken[6].c_str());
		tempEdge.t_x = atof(vecToken[7].c_str());
		tempEdge.t_y = atof(vecToken[8].c_str());

		// Update max_node_id
		if(tempEdge.source > maxNode)
			maxNode = tempEdge.source;
		if(tempEdge.target > maxNode)
			maxNode = tempEdge.target;
		
		vecEdges.push_back(tempEdge);
	}

	edges = new edge_astar_t[edge_count];
	int i;

	for(i = 0; i < edge_count; i++)
	{
		edges[i] = vecEdges[i];
	}
	fclose(stdin);
}
コード例 #11
0
ファイル: dmzRuntimeConfig.cpp プロジェクト: ben-sangster/dmz
/*!

\brief Looks up all config contexts with the given name.
\details All config context found with a matching name are stored as children of \a data.
\param[in] Name String containing name of config contexts to lookup.
\param[out] data Config to store the found config contexts.
\return Returns dmz::True if any config contexts were found.

*/
dmz::Boolean
dmz::Config::lookup_all_config (const String &Name, Config &data) const {

   Boolean result (False);
   StringTokenizer it (Name, LocalScopeChar);
   String sub = it.get_next ();
   Boolean done (!sub ? True : False);

   Config prev ("prev");
   prev.add_config (*this);
   Config current (sub);

   while (!done) {

      ConfigIterator tableIt;
      Config next;

      ConfigContext *curContext = current.get_config_context ();

      while (prev.get_next_config (tableIt, next)) {

         ConfigContext *nextContext = next.get_config_context ();

         if (nextContext && curContext) {

            ConfigContext::DataList *dl (nextContext->configTable.lookup (sub));

            if (dl) {

               dl->lock.lock ();
                  ConfigContext::DataStruct *ds = dl->head;
                  while (ds) {

                     if (ds->handle) {

                        curContext->add_config (ds->context);
                     }

                     ds = ds->next;
                  }
               dl->lock.unlock ();
            }
         }
      }

      if (current.is_empty ()) { done = True; }
      else {

         sub = it.get_next ();
         if (!sub) { data = current; done = True; result = True; }
         else { prev = current; Config next (sub); current = next; }
      }
   }

   if (data.is_empty ()) { data.set_config_context (0); result = False; }

   return result;
}
コード例 #12
0
ファイル: testrdp.cpp プロジェクト: bsaunder/aoPHP
bool inFailList(int s){
    StringTokenizer strtok = StringTokenizer(src,",");
    while(strtok.hasMoreTokens()){
        string cur = strtok.nextToken();
        int c = atoi(cur.c_str());
        if(c==s) return true;
    }
    return false;
}
コード例 #13
0
void ImplicitTagRulesDatabaseDeriver::_populateSchemaTagValues()
{
  _schemaTagValues.clear();
  _wordsNotInSchema.clear();

  // TODO: should the use and/or building categories be added here?
  const std::vector<SchemaVertex> tags =
    OsmSchema::getInstance().getTagByCategory(OsmSchemaCategory::poi());
  StringTokenizer tokenizer;
  for (std::vector<SchemaVertex>::const_iterator tagItr = tags.begin();
       tagItr != tags.end(); ++tagItr)
  {
    SchemaVertex tag = *tagItr;
    const QString tagVal = tag.value.toLower().replace("_", " ");
    if (!tagVal.contains("*"))  //skip wildcards
    {
      if (!_customRules.getWordIgnoreList().contains(tagVal, Qt::CaseInsensitive))
      {
        _schemaTagValues.insert(tagVal);
        //dealing with the uk english spellings on an as seen basis; this should be expanded and
        //made more extensible
        if (tagVal == "theatre")
        {
          _schemaTagValues.insert("theater");
        }
        if (tagVal == "centre")
        {
          _schemaTagValues.insert("center");
        }
        LOG_TRACE("Appended " << tagVal << " to schema tag values.");
      }
      QStringList vals = tokenizer.tokenize(tagVal);
      for (int i = 0; i < vals.size(); i++)
      {
        const QString val = vals.at(i);
        if (!_customRules.getWordIgnoreList().contains(val, Qt::CaseInsensitive))
        {
          _schemaTagValues.insert(val);
          //see comment above
          if (val == "theatre")
          {
            _schemaTagValues.insert("theater");
          }
          if (val == "centre")
          {
            _schemaTagValues.insert("center");
          }
          LOG_TRACE("Appended " << val << " to schema tag values.");
        }
      }
    }
  }
  LOG_VARD(_schemaTagValues.size());
  QStringList schemaTagValuesList = _schemaTagValues.toList();
  qSort(schemaTagValuesList.begin(), schemaTagValuesList.end()); //sort for viewing only
  LOG_VART(schemaTagValuesList);
}
コード例 #14
0
void MasterProcessSession::sendTile(const char *buffer, int length, StringTokenizer& tokens)
{
    int part, width, height, tilePosX, tilePosY, tileWidth, tileHeight;

    if (tokens.count() < 8 ||
        !getTokenInteger(tokens[1], "part", part) ||
        !getTokenInteger(tokens[2], "width", width) ||
        !getTokenInteger(tokens[3], "height", height) ||
        !getTokenInteger(tokens[4], "tileposx", tilePosX) ||
        !getTokenInteger(tokens[5], "tileposy", tilePosY) ||
        !getTokenInteger(tokens[6], "tilewidth", tileWidth) ||
        !getTokenInteger(tokens[7], "tileheight", tileHeight))
    {
        sendTextFrame("error: cmd=tile kind=syntax");
        return;
    }

    if (part < 0 ||
        width <= 0 ||
        height <= 0 ||
        tilePosX < 0 ||
        tilePosY < 0 ||
        tileWidth <= 0 ||
        tileHeight <= 0)
    {
        sendTextFrame("error: cmd=tile kind=invalid");
        return;
    }

    std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";

    std::vector<char> output;
    output.reserve(4 * width * height);
    output.resize(response.size());
    std::memcpy(output.data(), response.data(), response.size());

    std::unique_ptr<std::fstream> cachedTile = _tileCache->lookupTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight);
    if (cachedTile && cachedTile->is_open())
    {
        cachedTile->seekg(0, std::ios_base::end);
        size_t pos = output.size();
        std::streamsize size = cachedTile->tellg();
        output.resize(pos + size);
        cachedTile->seekg(0, std::ios_base::beg);
        cachedTile->read(output.data() + pos, size);
        cachedTile->close();

        sendBinaryFrame(output.data(), output.size());

        return;
    }

    if (_peer.expired())
        dispatchChild();
    forwardToPeer(buffer, length);
}
コード例 #15
0
ファイル: MPSReader.cpp プロジェクト: vinishiru/cuda-simplex
void MPSReader::readNAME(){

  line = fileReader->readLine();
  StringTokenizer *lineTokens = new StringTokenizer(line);

  if (lineTokens->nextToken().compare("NAME") == 0)
  {
    funcao->NomeProblema = lineTokens->nextToken();
  }
}
コード例 #16
0
int TargetBasedReplicationController::configure (ConfigManager *pCfgMgr)
{
    const char *pszMethod = "TargetBasedReplicationController::configure";

    // Load the target specifications from config file
    const char *pszIncludedTargets = pCfgMgr->getValue ("aci.disService.replicationTarget.includeList");
    const char *pszExcludedTargets = pCfgMgr->getValue ("aci.disService.replicationTarget.excludeList");

    // Parse the targets into arrays
    if (pszIncludedTargets) {
        StringTokenizer tokenizer (pszIncludedTargets, ';');
        const char *pszToken;
        while ((pszToken = tokenizer.getNextToken()) != NULL) {
            String *pTargetId = new String (pszToken);
            _targetIncludeSpec.append (pTargetId);
            checkAndLogMsg (pszMethod, Logger::L_Info,
                            "added %s as an included target specification\n", pszToken);
        }
    }
    if (pszExcludedTargets) {
        StringTokenizer tokenizer (pszExcludedTargets, ';');
        const char *pszToken;
        while ((pszToken = tokenizer.getNextToken()) != NULL) {
            String *pTargetId = new String (pszToken);
            _targetExcludeSpec.append (pTargetId);
            checkAndLogMsg (pszMethod, Logger::L_Info,
                            "added %s as an excluded target specification\n", pszToken);
        }
    }

    // Determine whether the target's existing messages should be used as a filter
    _bCheckTargetForMsgs = pCfgMgr->getValueAsBool ("aci.disService.replication.checkTargetForMsgs", true);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "check target's existing messages for filtration: %s\n",
                    _bCheckTargetForMsgs ? "true" : "false");

    // Check whether replicated messages should be acknowledged
    _bRequireAcks = pCfgMgr->getValueAsBool ("aci.disService.replication.requireAcks", true);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "require acknowledgements: %s\n",
                    _bRequireAcks ? "true" : "false");

    // Check whether we should perform concurrent replication (to multiple target peers)
    _bAllowConcurrentReplication = pCfgMgr->getValueAsBool ("aci.disService.replication.concurrentReplication", false);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "allow concurrent replication to multiple targets: %s\n",
                    _bAllowConcurrentReplication ? "true" : "false");

    // Check whether we should receive from multiple replications concurrently
    _bAllowConcurrentReception = pCfgMgr->getValueAsBool ("aci.disService.replication.concurrentReception", false);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "allow concurrent reception from multiple replicators: %s\n",
                    _bAllowConcurrentReception ? "true" : "false");
    return 0;
}
コード例 #17
0
ファイル: expr.cpp プロジェクト: nmmmnu/ccc
expr_type Calculator::calc1(const char *expr){
   StringTokenizer *st = new StringTokenizer(expr, EDELIMITERS);

   MathTok m[len + 1];

   size_t co = 0;

   sign_type sign = E_PLUS;

   const char *x = st->nextToken();

   while (x && co < len){
      m[co].value = atoexpr(x);
      m[co].proc  = sign;

      //printf("%-3d %5.2f %d %s\n", e_matrix[ m[co].proc ]->sign, m[co].value, err, st->nextToEnd());

      co++;
      sign = chk_sign(st->lastdelimiter, st, &err);

      x = st->nextToken();
   }

   delete(st);

   while(co > 1){
      size_t i;

      unsigned short int pr  = e_matrix[ m[0 + 1].proc ]->priority;

      for (i = 0 + 1; i < co; i++){
         unsigned short int pr1 = e_matrix[ m[i].proc ]->priority;
         if (pr1 > pr)
            pr = pr1;
      }

      for (i = 0 + 1; i < co; i++)
         if (e_matrix[ m[i].proc ]->priority == pr){
            if (e_matrix[ m[i].proc ]->process == NULL)
               err = true;
            else
               m[i - 1].value = e_matrix[ m[i].proc ]->process(m[i - 1].value, m[i].value, &err);

            for (size_t j = i; j < co - 1; j++)
               m[j]=m[j + 1];

            co--;

            break;
         }
   }

   return m[0].value;
}
コード例 #18
0
ファイル: ImageLayer.cpp プロジェクト: samuelpauls/Xeno-Story
bool ImageLayer::process_command (const std::string &command) throw() {
  if (!command.empty()) {
    StringTokenizer tokens (command);
    std::string action = tokens.get_next_string();
    if (action == "set_background_image") {
      std::string filename = tokens.get_next_string();
      set_animation (new Animation ("image_layers/" + filename), filename);
      return true;
    } // if a particular action
  }
  return false;
}
コード例 #19
0
ファイル: Tree.cpp プロジェクト: ddalevi/PSTk-Classifier
void Tree::checkNumberTokens( StringTokenizer& str, const int& n,
			      const string& tag, const int& ln )
{
  if( n != str.countTokens() ) 
    {
      cerr << "The input-file seems corrupt for the " << Node::getAlphabetName() << " alphabet, line: " << ln << endl << tag << " ";
      cerr << "Line has " << str.countTokens()+1 << " space separated words, should have: " << n + 1 << endl;
      while( str.hasMoreTokens() )cout << str.nextToken() << " ";
      cout << endl;
      exit( 2 ); // THROW EXCEPTION!!
    }
}
コード例 #20
0
 opennlp::model::Event *FileEventStream::next()
 {
   StringTokenizer *st = new StringTokenizer(line);
   std::string outcome = st->nextToken();
   int count = st->countTokens();
   std::string context[count];
   for (int ci = 0; ci < count; ci++)
   {
     context[ci] = st->nextToken();
   }
   return (new Event(outcome, context));
 }
コード例 #21
0
ファイル: expr.old.2.cpp プロジェクト: nmmmnu/ccc
long int calc(const char *expr){
   StringTokenizer *st = new StringTokenizer(expr, EDELIMITERS);
   
   MathTok *m[100 + 1];
   unsigned int co = 0;
   char znak = CEPLUS;

   const char *x = st->nextToken();
   while (x){
      switch  (znak){
         case CEPLUS  : m[co] = new MathTok_PLUS (x); break;
         case CEMINUS : m[co] = new MathTok_MINUS(x); break;
         case CESTAR  : m[co] = new MathTok_STAR (x); break;
         case CESLASH : m[co] = new MathTok_SLASH(x); break;
         case CEGREAT : m[co] = new MathTok_GREAT(x); break;
         case CELESS  : m[co] = new MathTok_LESS (x); break;
         case CEEQUAL : m[co] = new MathTok_EQUAL(x); break;

         default      : m[co] = new MathTok_PLUS (x); break;
      }
      co++;
      znak = st->lastdelimiter;
      x = st->nextToken();
   }

   delete(st);

   while(co > 1){
      unsigned int i;

      unsigned short int pr = m[0 + 1]->getPriority();
      for (i = 0 + 1; i < co; i++)
         if (m[i]->getPriority() > pr)
            pr = m[i]->getPriority();

      for (i = 0 + 1; i < co; i++)
         if (m[i]->getPriority() == pr){
            m[i - 1]->value = m[i]->calc( m[i - 1]->value );

            for (unsigned int j = i; j < co - 1; j++)
               m[j]=m[j + 1];

            co--;

            break;
         }
   }

   return m[0]->value;
}
コード例 #22
0
ファイル: MPSReader.cpp プロジェクト: vinishiru/cuda-simplex
void MPSReader::readCOLUMNS(){

  StringTokenizer *lineTokens = new StringTokenizer(line);
  string nomeFuncao;
  string nomeVariavel;
  string valorVariavel;

  if (lineTokens->nextToken().compare("COLUMNS") == 0){

    line = fileReader->readLine();

    while (line.compare("RHS") != 0){

      lineTokens->setLine(line);

      //Ler no minimo 3 tokens
      //Nome variavel / Nome Funcao|Restricao / Valor variavel

      nomeVariavel = lineTokens->nextToken();
      nomeFuncao = lineTokens->nextToken();
      valorVariavel = lineTokens->nextToken();

      //Se nomeFuncao for o nome da funcao objetivo, atribuir variaveis nela
      if (nomeFuncao.compare(funcao->Nome) == 0){
        funcao->addVariavel(nomeVariavel, stof(valorVariavel.c_str()));
      }
      //Se nao, atribuir variaveis a restricao
      else {
        funcao->addVariavelRestricao(nomeFuncao, nomeVariavel, stof(valorVariavel.c_str()));
      }

      //Se tiver mais tokens, ler mais duas colunas
      //Nome Variavel e Valor Variavel, obedecendo as mesmas regras anteriores
      if (lineTokens->hasToken()){
        nomeFuncao = lineTokens->nextToken();
        valorVariavel = lineTokens->nextToken();

        //Se nomeFuncao for o nome da funcao objetivo, atribuir variaveis nela
        if (nomeFuncao.compare(funcao->Nome) == 0){
          funcao->addVariavel(nomeVariavel, stof(valorVariavel.c_str()));
        }
        //Se nao, atribuir variaveis a restricao
        else {
          funcao->addVariavelRestricao(nomeFuncao, nomeVariavel, stof(valorVariavel.c_str()));
        }
      }


      line = fileReader->readLine(); //ler nova linha ao final
    }
  }

}
コード例 #23
0
QueryQualifierBuilder * QueryQualifierBuilder::parse (const char *pszQueryQualifiers)
{
    if (pszQueryQualifiers == NULL) {
        return NULL;
    }

    unsigned int uiLen = strlen (pszQueryQualifiers);
    if (uiLen == 0) {
        return NULL;
    }

    BufferReader br (pszQueryQualifiers, uiLen, false);
    LineOrientedReader lr (&br, false);
    char *pszLine = (char *) calloc (uiLen+1, sizeof (char));
    if (pszLine == NULL) {
        return NULL;
    }
    QueryQualifierBuilder *pQualifierBuilder = new QueryQualifierBuilder();
    if (pQualifierBuilder == NULL) {
        free (pszLine);
        return NULL;
    }

    for (int rc; (rc = lr.readLine (pszLine, uiLen)) >= 0;) {
        if (rc == 0) {
            continue;   // empty line
        }
        static StringTokenizer tokenizer;
        tokenizer.init (pszQueryQualifiers, ';', ';');
        for (const char *pszToken; (pszToken = tokenizer.getNextToken()) != NULL;) {
            if (pQualifierBuilder->setArgument (*pQualifierBuilder, pszToken) < 0) {
                free (pszLine);
                free (pQualifierBuilder);
                return NULL;
            }
        }
    }

    free (pszLine);
    
  /*  if (pszQueryQualifiers->_groupBy.) {
        
    }
            NOMADSUtil::String _limit;
            NOMADSUtil::String _order;*/

    return pQualifierBuilder;
}
コード例 #24
0
bool ChildProcessSession::mouseEvent(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    int type, x, y, count, buttons, modifier;

    if (tokens.count() != 7 ||
        !getTokenKeyword(tokens[1], "type",
                         {{"buttondown", LOK_MOUSEEVENT_MOUSEBUTTONDOWN},
                          {"buttonup", LOK_MOUSEEVENT_MOUSEBUTTONUP},
                          {"move", LOK_MOUSEEVENT_MOUSEMOVE}},
                         type) ||
        !getTokenInteger(tokens[2], "x", x) ||
        !getTokenInteger(tokens[3], "y", y) ||
        !getTokenInteger(tokens[4], "count", count) ||
        !getTokenInteger(tokens[5], "buttons", buttons) ||
        !getTokenInteger(tokens[6], "modifier", modifier))
    {
        sendTextFrame("error: cmd=mouse kind=syntax");
        return false;
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);
    _loKitDocument->pClass->postMouseEvent(_loKitDocument, type, x, y, count, buttons, modifier);

    return true;
}
コード例 #25
0
ファイル: ChildSession.cpp プロジェクト: biostone/online
bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int type, x, y;

    if (tokens.count() != 4 ||
        !getTokenKeyword(tokens[1], "type",
                         {{"start", LOK_SETGRAPHICSELECTION_START},
                          {"end", LOK_SETGRAPHICSELECTION_END}},
                         type) ||
        !getTokenInteger(tokens[2], "x", x) ||
        !getTokenInteger(tokens[3], "y", y))
    {
        sendTextFrame("error: cmd=selectgraphic kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    _loKitDocument->setGraphicSelection(type, x, y);

    return true;
}
コード例 #26
0
ファイル: ChildSession.cpp プロジェクト: biostone/online
bool ChildSession::clientVisibleArea(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int x;
    int y;
    int width;
    int height;

    if (tokens.count() != 5 ||
        !getTokenInteger(tokens[1], "x", x) ||
        !getTokenInteger(tokens[2], "y", y) ||
        !getTokenInteger(tokens[3], "width", width) ||
        !getTokenInteger(tokens[4], "height", height))
    {
        sendTextFrame("error: cmd=clientvisiblearea kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    _loKitDocument->setClientVisibleArea(x, y, width, height);
    return true;
}
コード例 #27
0
ファイル: ChildSession.cpp プロジェクト: biostone/online
bool ChildSession::paste(const char* buffer, int length, StringTokenizer& tokens)
{
    std::string mimeType;

    if (tokens.count() < 2 || !getTokenString(tokens[1], "mimetype", mimeType))
    {
        sendTextFrame("error: cmd=paste kind=syntax");
        return false;
    }

    const std::string firstLine = getFirstLine(buffer, length);
    const char* data = buffer + firstLine.size() + 1;
    size_t size = length - firstLine.size() - 1;

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    Log::info("Calling _loKit->paste()");
    _loKitDocument->paste(mimeType.c_str(), data, size);
    Log::info("paste() returned");

    return true;
}
コード例 #28
0
ファイル: ChildSession.cpp プロジェクト: biostone/online
bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    std::string name, type;

    if (tokens.count() != 3 ||
        !getTokenString(tokens[1], "name", name) ||
        !getTokenString(tokens[2], "type", type))
    {
        sendTextFrame("error: cmd=insertfile kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (type == "graphic")
    {
        std::string fileName = "file://" + std::string(JAILED_DOCUMENT_ROOT) + "insertfile/" + name;
        std::string command = ".uno:InsertGraphic";
        std::string arguments = "{"
            "\"FileName\":{"
                "\"type\":\"string\","
                "\"value\":\"" + fileName + "\""
            "}}";
        if (_multiView)
            _loKitDocument->setView(_viewId);

        _loKitDocument->postUnoCommand(command.c_str(), arguments.c_str(), false);
    }

    return true;
}
コード例 #29
0
bool MasterProcessSession::loadDocument(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    if (tokens.count() < 2)
    {
        sendTextFrame("error: cmd=load kind=syntax");
        return false;
    }

    std::string timestamp;
    parseDocOptions(tokens, _loadPart, timestamp);

    try
    {
        Poco::URI aUri(_docURL);

        // request new URL session
        const std::string aMessage = "request " + getId() + " " + _docURL + "\r\n";
        Log::trace("MasterToBroker: " + aMessage);
        Util::writeFIFO(LOOLWSD::BrokerWritePipe, aMessage);
    }
    catch (const Poco::SyntaxException&)
    {
        sendTextFrame("error: cmd=load kind=uriinvalid");
        return false;
    }

    _tileCache.reset(new TileCache(_docURL, timestamp));

    // Finally, wait for the Child to connect to Master,
    // link the document in jail and dispatch load to child.
    dispatchChild();

    return true;
}
コード例 #30
0
bool ChildProcessSession::insertFile(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    std::string name, type;

    if (tokens.count() != 3 ||
        !getTokenString(tokens[1], "name", name) ||
        !getTokenString(tokens[2], "type", type))
    {
        sendTextFrame("error: cmd=insertfile kind=syntax");
        return false;
    }

    Poco::Mutex::ScopedLock lock(_mutex);

    if (type == "graphic")
    {
        std::string fileName = "file://" + JailedDocumentRoot + "insertfile/" + name;
        std::string command = ".uno:InsertGraphic";
        std::string arguments = "{"
            "\"FileName\":{"
                "\"type\":\"string\","
                "\"value\":\"" + fileName + "\""
            "}}";
        _loKitDocument->pClass->setView(_loKitDocument, _viewId);
        _loKitDocument->pClass->postUnoCommand(_loKitDocument, command.c_str(), arguments.c_str(), false);
    }

    return true;
}