Ejemplo n.º 1
0
/* ****************************************************************************
*
* xmlParse - 
*
* This function is called once (actually it is not that simple) for each node in
* the tree that the XML parser has built for us.
* 
*
* In the node '<contextValue>', isCompoundValuePath returns TRUE.
* Under "<contextValue>", we have either a simple string or a Compound Value Tree.
* In the case of a "simple string" the value of the current node is NON EMPTY,
* and as the node is treated already in the previous call to 'treat()', no further action is needed.
*
* If a node is NOT TREATED and it is NOT a compound, a parse error is issued
*/
void xmlParse
(
   ConnectionInfo*     ciP,
   xml_node<>*         father,
   xml_node<>*         node,
   const std::string&  indentation,
   const std::string&  fatherPath,
   XmlNode*            parseVector,
   ParseData*          parseDataP
)
{
  std::string  value            = wsStrip(node->value());
  std::string  name             = wsStrip(node->name());
  std::string  path             = fatherPath + "/" + name;
  bool         treated          = treat(node, path, parseVector, parseDataP);

  if (isCompoundValuePath(path.c_str()) && (value == "") && (node->first_node() != NULL))
  {
    //
    // Count children (to avoid false compounds because of just en empty sttribute value)
    // 
    xml_node<>* child    = node->first_node();
    int         children = 0;
    while (child != NULL)
    {
      if (child->name()[0] != 0)
        ++children;
      child = child->next_sibling();
    }
    
    if (children == 0) // NOT a compound value
      return;

    eatCompound(ciP, NULL, node, "");
    compoundValueEnd(ciP, parseDataP);
    return;
  }
  else  if (treated == false)
  {
    ciP->httpStatusCode = SccBadRequest;
    if (ciP->answer == "")
      ciP->answer = std::string("Unknown XML field: '") + name.c_str() + "'";
    LM_W(("ERROR: '%s', PATH: '%s'   ", ciP->answer.c_str(), fatherPath.c_str()));
    return;
  }

  // Recursive calls for all children of this node
  xml_node<>* child = node->first_node();
  while (child != NULL)
  {
    if ((child != NULL) && (child->name() != NULL) && (onlyWs(child->name()) == false))
      xmlParse(ciP, node, child, indentation + "  ", path, parseVector, parseDataP);

    child = child->next_sibling();
  }
}
Ejemplo n.º 2
0
static char	*egalize(t_player *player, const t_server *server, int i)
{
  t_square	*sq;
  char		*ret;
  int		x;
  int		y;

  ret = "";
  x = player->x + vision[player->direction][i][0];
  y = player->y + vision[player->direction][i][1];
  sq =
    server->game->world->map->
    at(server->game->
       world->map, POS_LIST(ABS_X(x, server->game->
				  world->width),
			    ABS_Y(y, server->
				  game->world->
				  height),
			    server->game->world->width));
  ret = my_concat(ret, treat(sq, server, x, y), NULL);
  return (ret);
}
Ejemplo n.º 3
0
  TEST_F(TrackerTest, runWorker)
  {
    MockTracker mockTracker;
    EXPECT_CALL(mockTracker, runWorker())
      .WillOnce(Invoke(&mockTracker, &MockTracker::TrackerRunWorker));

    mockTracker._newClient.push(new Client(NULL));
    mockTracker._newClient.push(new Client(NULL));
    mockTracker._newClient.push(new Client(NULL));

    EXPECT_CALL(mockTracker, treat(_)).Times(3);
    
    EXPECT_CALL(mockTracker, reply(_))
      .WillOnce(Return())
      .WillOnce(Return())
      .WillOnce(Invoke(this,&TrackerTest::exitRunning2));

    mockTracker._run = true;
    mockTracker.runWorker();

    EXPECT_TRUE(mockTracker._newClient.empty());
  }