Esempio n. 1
0
static void
parseStyle (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb)
{
  xmlChar *content;
  xmlChar *prop;
  int start = fb->utf8_current_index;

  prop = xmlGetProp(cur, (const xmlChar *)"name");

  cur = cur->children;

  while (cur != NULL) {

    if (xmlNodeIsText(cur)) {
      content = xmlNodeGetContent(cur);
      if (content)
	bufferAppend(content, xmlStrlen(content), fb);
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"style")) {
      parseStyle(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"strong")) {
      content = xmlNodeGetContent(cur->children);
      if (content) {
	int st = fb->utf8_current_index;
	bufferAppend(content, xmlStrlen(content), fb);
	addMark(st, fb->utf8_current_index, STRONG_TYPE, NULL, fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"emphasis")) {
      content = xmlNodeGetContent(cur->children);
      if (content) {
	int st = fb->utf8_current_index;
	bufferAppend(content, xmlStrlen(content), fb);
	addMark(st, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"a")) {
      parseLink(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) {
      parseImage(doc, cur, fb);

    }

    cur = cur->next;
  }

  if (prop && (!xmlStrcmp(prop, (const xmlChar *)"italic"))) {
    addMark(start, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb);
    xmlFree(prop);
  }

  return;
}
Esempio n. 2
0
bool StJpegParser::parse() {
    if(myBuffer == NULL) {
        return false;
    }

    int aCount = 0;
    myImages = parseImage(++aCount, 1, myBuffer, false);
    if(myImages.isNull()) {
        return false;
    }

    // continue reading the file (MPO may contains more than 1 image)
    for(StHandle<StJpegParser::Image> anImg = myImages;
        !anImg.isNull(); anImg = anImg->Next) {
        anImg->Next = parseImage(++aCount, 1, anImg->Data + anImg->Length, true);
    }

    return true;
}
void DenseDescriptorDictionaryTrainer::train()
{
	//parse training images
	parseImage();

	//write to output signal
	InfoSignal<std::string>* output_signal_info = TO_INFO_SIGNAL(std::string,getOutputPort(OUTPUT_PORT_DIC_FILE_INFO));
	m_trainer_info = m_trainer_name;
	output_signal_info->info = &m_trainer_info;

	EAGLEEYE_INFO("success to build dictionary (%s)\n",m_trainer_name.c_str());
}
Esempio n. 4
0
	bool ImageExportSerializer::deserialization(pugi::xml_document& _doc)
	{
		if (_doc.select_single_node("MyGUI[@type=\"Resource\"]").node().empty())
			return false;

		pugi::xpath_node_set nodes = _doc.select_nodes("MyGUI/Resource[@type=\"ResourceImageSet\"]");
		for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
			parseImage((*node).node());

		updateImageProperty(DataManager::getInstance().getRoot());
		return true;
	}
Esempio n. 5
0
static void
parseSection (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb)
{
  FB2Mark *mark;

  mark = getLink(cur, fb);

  cur = cur->children;
  while (cur != NULL) {

    if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) {
      parseTitle(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"section")) {
      parseSection(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"poem")) {
      parsePoem(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"cite")) {
      parseCite(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) {
      parseEpigraph(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"p")) {
      parseP(doc, cur, 1, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"subtitle")) {
      int start = fb->utf8_current_index;
      parseP(doc, cur, 0, fb);
      addMark(start, fb->utf8_current_index, BOOKMARK_TYPE, NULL, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"empty-line")) {
      bufferAppend("\n", 1, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) {
      parseImage(doc, cur, fb);
    }

    cur = cur->next;
  }

  if (mark)
    mark->link_end = fb->text_current_index;

  return;
}
Esempio n. 6
0
std::vector<Image> LevelModel::parseImages (QXmlStreamReader* aXmlStreamReader)
{
    assert(aXmlStreamReader);
    //CrashLogger logger("LevelManager::parseImages");
    std::vector<Image> result;
    while (!aXmlStreamReader->atEnd() &&
           !(aXmlStreamReader->isEndElement() && aXmlStreamReader->name() == "images")) {
        aXmlStreamReader->readNext();
        if (aXmlStreamReader->isStartElement()) {
            if (aXmlStreamReader->name() == "imagedesc") {
                result.push_back(parseImage(aXmlStreamReader));
            }
        }
    }
    return result;
}
Esempio n. 7
0
static void
parse_doc(xmlDocPtr doc) {
  xmlNodePtr cur;

  cur = xmlDocGetRootElement(doc);
  if (cur == NULL) {
    g_warning("empty document\n");
    xmlFreeDoc(doc);
    return;
  }
  cur = cur->xmlChildrenNode;

  while (cur != NULL) {
    if ((!xmlStrcmp(cur->name, (const xmlChar *)"ImageSet"))){
      parseImage (doc, cur);
    }

    cur = cur->next;
  }

  return;
}
Esempio n. 8
0
static void
parseBody (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb)
{
  xmlChar *prop;

  prop = xmlGetProp(cur, (const xmlChar *)"name");
  if (prop) {
    int start = fb->utf8_current_index;
    bufferAppend("\n\n", 2, fb);
    bufferAppend(prop, xmlStrlen(prop), fb);
    bufferAppend("\n\n", 2, fb);
    addMark(start, fb->utf8_current_index, BOOKMARK_TYPE, NULL, fb);
    xmlFree(prop);
  }


  cur = cur->children;
  while (cur != NULL) {

    if (!xmlStrcmp(cur->name, (const xmlChar *)"section")) {
      parseSection(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) {
      parseTitle(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) {
      parseImage(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) {
      parseEpigraph(doc, cur, fb);

    }


    cur = cur->next;
  }
  return;
}
Esempio n. 9
0
    CatalogEntry * CatalogEntry::factory ( const std::string & path, Server * server )
    {
        std::ifstream f ( "data/" + path );

        if ( ! f.is_open ( ) )
        {
            std::cerr << "Unable to open stream file '" << path << "'" << std::endl;
            return nullptr;
        }

        std::string tmp;

        uint32_t stream_id;
        std::string stream_name, stream_addr;
        CatalogEntry::Type stream_type;
        CatalogEntry::Protocol stream_protocol;
        uint16_t stream_port;
        uint16_t stream_ips;

        // ID
        {
            Vod_parseNumberMin ( 1, "ID", nullptr, 1 );
            stream_id = ( uint32_t ) tmpNumber;
        }

        // Name
        {
            Vod_parse ( 2, "Name", nullptr );
            stream_name = tmp;
        }

        // Type
        {
            Vod_parse ( 3, "Type", nullptr );
            if ( ! CatalogEntry::stringToType ( tmp, stream_type ) )
            {
                std::cerr << "Stream Type after 'Type: ' at line 3 is unvalid" << std::endl;
                return nullptr;
            }
        }

        // Address
        {
            Vod_parse ( 4, "Address", nullptr );
            stream_addr = tmp;
        }

        // Port
        {
            Vod_parseNumberMinMax ( 5, "Port", nullptr, VOD_MIN_PORT, VOD_MAX_PORT );
            stream_port = ( uint16_t ) tmpNumber;
        }

        // Protocol
        {
            Vod_parse ( 6, "Protocol", nullptr );
            if ( ! CatalogEntry::stringToProtocol ( tmp, stream_protocol ) )
            {
                std::cerr << "Stream Protocol after 'Protocol: ' at line 6 is unvalid" << std::endl;
                return nullptr;
            }
        }

        // IPS
        {
            Vod_parseNumberMin ( 7, "IPS", nullptr, 1 );
            stream_ips = ( uint16_t ) tmpNumber;
        }

        CatalogImages * pimages = new CatalogImages;
        // Image files
        {
            uint32_t imgCounter = 0;
            while ( customGetLine ( f, tmp ) )
            {
                if ( ! parseImage ( tmp ) )
                {
                    delete pimages;
                    return nullptr;
                }

                pimages -> insert ( { ++imgCounter, tmp } );
            }
        }

        CatalogEntry * catalogEntry = nullptr;

        switch ( stream_protocol )
        {
            case TCP_PULL:
                catalogEntry = new TcpPull::Server;
                break;

            case TCP_PUSH:
                catalogEntry = new TcpPush::Server;
                break;

            case UDP_PULL:
            case UDP_PUSH:
                return nullptr;
        }

        catalogEntry -> fill (
            stream_id,
            stream_name,
            stream_type,
            stream_addr,
            stream_port,
            stream_protocol,
            stream_ips,
            pimages,
            server );

        return catalogEntry;
    }
 void DirectionReader::parseDirectionType( const core::DirectionType& directionType )
 {
     switch ( directionType.getChoice() )
     {
         case core::DirectionType::Choice::rehearsal:
         {
             parseRehearsal( directionType );
             break;
         }
         case core::DirectionType::Choice::segno:
         {
             parseSegno( directionType );
             break;
         }
         case core::DirectionType::Choice::words:
         {
             parseWords( directionType );
             break;
         }
         case core::DirectionType::Choice::coda:
         {
             parseCoda( directionType );
             break;
         }
         case core::DirectionType::Choice::wedge:
         {
             parseWedge( directionType );
             break;
         }
         case core::DirectionType::Choice::dynamics:
         {
             parseDynamics( directionType );
             break;
         }
         case core::DirectionType::Choice::dashes:
         {
             parseDashes( directionType );
             break;
         }
         case core::DirectionType::Choice::bracket:
         {
             parseBracket( directionType );
             break;
         }
         case core::DirectionType::Choice::pedal:
         {
             parsePedal( directionType );
             break;
         }
         case core::DirectionType::Choice::metronome:
         {
             parseMetronome( directionType );
             break;
         }
         case core::DirectionType::Choice::octaveShift:
         {
             parseOctaveShift( directionType );
             break;
         }
         case core::DirectionType::Choice::harpPedals:
         {
             parseHarpPedals( directionType );
             break;
         }
         case core::DirectionType::Choice::damp:
         {
             parseDamp( directionType );
             break;
         }
         case core::DirectionType::Choice::dampAll:
         {
             parseRehearsal( directionType );
             break;
         }
         case core::DirectionType::Choice::eyeglasses:
         {
             parseEyeglasses( directionType );
             break;
         }
         case core::DirectionType::Choice::stringMute:
         {
             parseStringMute( directionType );
             break;
         }
         case core::DirectionType::Choice::scordatura:
         {
             parseScordatura( directionType );
             break;
         }
         case core::DirectionType::Choice::image:
         {
             parseImage( directionType );
             break;
         }
         case core::DirectionType::Choice::principalVoice:
         {
             parsePrincipalVoice( directionType );
             break;
         }
         case core::DirectionType::Choice::accordionRegistration:
         {
             parseAccordionRegistration( directionType );
             break;
         }
         case core::DirectionType::Choice::percussion:
         {
             parsePercussion( directionType );
             break;
         }
         case core::DirectionType::Choice::otherDirection:
         {
             parseOtherDirection( directionType );
             break;
         }
         default: break;
     }
 }
Esempio n. 11
0
File: plotd.c Progetto: am1337/plotd
int manualControl(void)
{
  int input;
  
  do
  {
    printf("\n");
    input = getInputChar();
    
    switch (input)
    {
      case 'w':
	moveUp(JUMP);
	break;
      case 'x':
	moveDown(JUMP);
	break;
      case 'd':
	moveRight(JUMP);	 
	break;
      case 'a':
	moveLeft(JUMP);
	break;
 
      case 'z':
	setZero(JUMP);	 
	break;
      case 'm':
	getMax(JUMP);
	break;
      case 'p':
	printf("Current position X:%d, Y:%d\n",posX,posY);
	break;
      case 'r':
	printf("Parsing input.nc\n");
	readGCodeFile("input.nc");
	break;
      case 'o':
	do {
	  printf("Set offset to:\n");
	  printf("0) none (default)\n");
	  printf("1) A4\n");
	  input=getInputChar();
	}
	while (input<'0'||input>'1');
	
	if(input=='0')
	{
	  setZero(JUMP);
	}
	else
	{
	  setZero(JUMP);
	  printf("Set offset to A4\n");
	  move2pos(47, 0, JUMP);
	  posX = 0;
	  posY = 0;
	  printf("offset reached\n");
	}
	break;
	break;
      case 'l':
	do {
	  printf("Set laser output power to:\n");
	  printf("1) low\n");
	  printf("2) medium (default)\n");
	  printf("3) high\n");
	  printf("4) maximum\n");
	  input=getInputChar();
	}
	while (input<'1'||input>'4');
	if(input=='4')
	{
	  laserPower=POW_MAX;
	  printf("Setting laser to maximum output power\n");
	}
	else if(input=='3')
	{
	  laserPower=POW_HI;
	  printf("Setting laser to high output power\n");
	}
	else if(input=='2')
	{
	  laserPower=POW_MED;
	  printf("Setting laser to medium output power\n");
	}
	else
	{
	  laserPower=POW_LOW;
	  printf("Setting laser to low output power\n");
	}
	break;
	
      case 's':
	do {
	  printf("Set speed to:\n");
	  printf("0) auto (default)\n");
	  printf("1) SNAIL\n");
	  printf("2) XSLOW\n");
	  printf("3) SLOW\n");
	  printf("4) MEDIUM\n");
	  printf("5) FAST\n");
	  input=getInputChar();
	}
	while (input<'0'||input>'5');
	
	if(input=='5')
	{
	  autoSpeed=FALSE;
	  manSpeed = FAST;
	  printf("Setting speed to FAST\n");
	}
	else if(input=='4')
	{
	  autoSpeed=FALSE;
	  manSpeed = MEDIUM;
	  printf("Setting speed to MEDIUM\n");
	}
	else if(input=='3')
	{
	  autoSpeed=FALSE;
	  manSpeed = SLOW;
	  printf("Setting speed to SLOW\n");
	}
	else if(input=='2')
	{
	  autoSpeed=FALSE;
	  manSpeed = XSLOW;
	  printf("Setting speed to XSLOW\n");
	}
	else if(input=='1')
	{
	  autoSpeed=FALSE;
	  manSpeed = SNAIL;
	  printf("Setting speed to SNAIL\n");
	}
	else
	{
	  autoSpeed=TRUE;
	  printf("Setting speed to auto\n");
	}
	break;
	
      case 'b':
	initImageIn();
	parseImage();
	drawImage();
	break;
      case 'q':
	exit(0);
	break;
      default:
	printf("available functions:\n");
	printf("w		move up\n");
	printf("x		move down\n");
	printf("d		move right\n");
	printf("a		move left\n");
	printf("z		move to pos 0/0 and reset step counter\n");
	printf("m		move to max position\n");
	printf("l		set power of laser\n");
	printf("s		set speed\n");
	printf("o		set offset\n");
	printf("p		print current position\n");
	printf("r 		read and plot file\n");
	printf("h		show this help\n");
	printf("q		quit\n");
	printf("b		read bitmap\n");
	printf("b		set lines to skip\n");// todo
	break;
    }
    setLaser(POW_OFF);
    pfio_write_output(0x00);
  }
  while (input != 'q');
	 
	 return OK;
}
Esempio n. 12
0
ParsedPage HtmlApi::parsePage(Page *parentPage, const QString &source, int first, int limit) const
{
	ParsedPage ret;

	// Getting tags
	if (contains("Regex/Tags"))
	{
		QList<Tag> tgs = Tag::FromRegexp(value("Regex/Tags"), source);
		if (!tgs.isEmpty())
		{ ret.tags = tgs; }
	}

	// Getting images
	QRegularExpression rxImages(value("Regex/Image"), QRegularExpression::DotMatchesEverythingOption);
	auto matches = rxImages.globalMatch(source);
	int id = 0;
	while (matches.hasNext())
	{
		auto match = matches.next();
		QMap<QString, QString> d = multiMatchToMap(match, rxImages.namedCaptureGroups());

		// JSON elements
		if (d.contains("json") && !d["json"].isEmpty())
		{
			QVariant src = Json::parse(d["json"]);
			if (!src.isNull())
			{
				QMap<QString, QVariant> map = src.toMap();
				for (auto it = map.begin(); it != map.end(); ++it)
				{ d[it.key()] = it.value().toString(); }
			}
		}

		QSharedPointer<Image> img = parseImage(parentPage, d, id + first);
		if (!img.isNull())
		{ ret.images.append(img); }

		id++;
	}

	// Navigation
	if (contains("Regex/NextPage"))
	{
		QRegularExpression rxNextPage(value("Regex/NextPage"));
		auto match = rxNextPage.match(source);
		if (match.hasMatch())
		{ ret.urlNextPage = QUrl(match.captured(1)); }
	}
	if (contains("Regex/PrevPage"))
	{
		QRegularExpression rxPrevPage(value("Regex/PrevPage"));
		auto match = rxPrevPage.match(source);
		if (match.hasMatch())
		{ ret.urlPrevPage = QUrl(match.captured(1)); }
	}

	// Last page
	if (contains("LastPage"))
	{ ret.pageCount = value("LastPage").toInt(); }
	else if (contains("Regex/LastPage"))
	{
		QRegularExpression rxlast(value("Regex/LastPage"));
		auto match = rxlast.match(source);
		int cnt = match.hasMatch() ? match.captured(1).remove(",").toInt() : 0;
		if (cnt > 0)
		{
			int pagesCount = cnt;
			if (value("Urls/Tags").contains("{pid}") || (contains("Urls/PagePart") && value("Urls/PagePart").contains("{pid}")))
			{
				int forced = forcedLimit();
				int ppid = forced > 0 ? forced : limit;
				pagesCount = qFloor(static_cast<qreal>(pagesCount) / static_cast<qreal>(ppid)) + 1;
			}
			ret.pageCount = pagesCount;
		}
	}

	// Count images
	if (contains("Regex/Count"))
	{
		QRegularExpression rxlast(value("Regex/Count"));
		auto match = rxlast.match(source);
		int cnt = match.hasMatch() ? match.captured(1).remove(",").toInt() : 0;
		if (cnt > 0)
		{ ret.imageCount = cnt; }
	}

	// Wiki
	if (contains("Regex/Wiki"))
	{
		QRegularExpression rxwiki(value("Regex/Wiki"), QRegularExpression::DotMatchesEverythingOption);
		auto match = rxwiki.match(source);
		if (match.hasMatch())
		{
			QString wiki = match.captured(1);
			wiki.remove("/wiki/show?title=");
			wiki.remove(QRegularExpression("<p><a href=\"([^\"]+)\">Full entry &raquo;</a></p>"));
			wiki.replace("<h6>", "<span class=\"title\">").replace("</h6>", "</span>");
			ret.wiki = wiki;
		}
	}

	return ret;
}