コード例 #1
0
ファイル: in_str.C プロジェクト: MarishaYasko/phantom
bool in_str_t::page_t::chunk(size_t off, str_t &str) const {
	if(off >= body.size())
		return false;

	str = str_t(body.ptr() + off, body.size() - off);
	return true;
}
コード例 #2
0
ファイル: time.C プロジェクト: MarishaYasko/phantom
string_t time_string(timeval_t time) {
	timestruct_t ts(time);

	unsigned int year = ts.year + 1;
	unsigned int day = ts.day + 1;

	return string_t::ctor_t(5 + 3 + 4 + 5 + 8 + 4)
		(str_t(wnames[ts.wday], 3))(',')(' ')                           // 5
		('0' + (day / 10) % 10)('0' + day % 10)(' ')                    // 3
		(str_t(mnames[ts.month], 3))(' ')                               // 4
		('0' + (year / 1000) % 10)('0' + (year / 100) % 10)
		('0' + (year / 10) % 10)('0' + year % 10)(' ')                  // 5
		('0' + (ts.hour / 10) % 10)('0' + ts.hour % 10)(':')
		('0' + (ts.minute / 10) % 10)('0' + ts.minute % 10)(':')
		('0' + (ts.second / 10) % 10)('0' + ts.second % 10)             // 8
		(CSTR(" GMT"))                                                  // 4
	;
}
コード例 #3
0
ファイル: kgamesvgdocument.cpp プロジェクト: jsj2008/kdegames
QString KGameSvgDocument::nodeToSvg() const
{
    QString s, t, xml, defs, pattern;
    QTextStream str(&s);
    QTextStream str_t(&t);
    QStringList defsAdded;
    int result = 0;
    QRegExp rx;

    currentNode().save(str, 1);
    xml = *str.string();

    // Find and add any required gradients or patterns
    pattern = QLatin1String( "url" ) + WSP_ASTERISK + OPEN_PARENS + WSP_ASTERISK + QLatin1String( "#(.*)" ) + WSP_ASTERISK + CLOSE_PARENS;
    rx.setPattern(pattern);
    if (rx.indexIn(xml, result) != -1)
    {
        QDomNode node, nodeBase;
        QString baseId;
        QDomNode n = def();

        result = 0;
        while ((result = rx.indexIn(xml, result)) != -1)
        {
            // Find the pattern or gradient referenced
            result += rx.matchedLength();
            if (!defsAdded.contains(rx.cap(1)))
            {
                node = d->findElementById(QLatin1String( "id" ), rx.cap(1), n);
                node.save(str_t, 1);
                defsAdded.append(rx.cap(1));
            }

            // Find the gradient the above gradient is based on
            baseId = node.toElement().attribute(QLatin1String( "xlink:href" )).mid(1);
            if (!defsAdded.contains(baseId))
            {
                nodeBase = d->findElementById(QLatin1String( "id" ), baseId, n);
                nodeBase.save(str_t, 1);
                defsAdded.append(baseId);
            }
        }
        defs = *str_t.string();
        defs = QLatin1String( "<defs>" ) + defs + QLatin1String( "</defs>" );
    }

    // Need to make node be a real svg document, so prepend and append required tags.
    xml = d->SVG_XML_PREPEND + defs + xml + d->SVG_XML_APPEND;
    return xml;
}
コード例 #4
0
ファイル: setup_module.C プロジェクト: MarishaYasko/phantom
void module_load(char const *file_name) {
	if(!dlopen(file_name, RTLD_NOW | RTLD_GLOBAL)) {
		char *err = dlerror();
/*
		if(err) {
			char *demangled = abi::__cxa_demangle(err, NULL, 0, NULL);
			if(demangled) {
				free(err); err = demangled;
			}
		}
*/
		if(!err)
			throw STRING("Unknown libdl error");

		string_t::ctor_t error_z(strlen(err) + 1);
		error_z(str_t(err, strlen(err)))('\0');

		free(err);

		throw string_t(error_z);
	}
}
コード例 #5
0
ファイル: time.C プロジェクト: MarishaYasko/phantom
string_t time_current_string(timeval_t &timeval_curr) {
	time_current_cache_t &cache = time_current_cache;

	timeval_t t = timeval::current();
	timeval_curr = t;

	uint64_t cache_time = (t - timeval::unix_origin) / interval::second;

	if(cache_time != cache.last_time) {
		unsigned long cache_date = cache_time / (60 * 60 * 24);

		if(cache_date != cache.last_date) {
			timestruct_t ts(t);

			copy3(wnames[ts.wday], cache.buf);
			dig2(ts.day + 1, cache.buf + 5);
			copy3(mnames[ts.month], cache.buf + 5 + 3);
			dig4(ts.year + 1, cache.buf + 5 + 3 + 4);

			cache.last_date = cache_date;
		}

		// (timeval::unix_origin - timeval::epch_origin) % (60 * 60 * 24) == 0

		unsigned int _time = cache_time % (60 * 60 * 24);

		dig2(_time % 60, cache.buf + 5 + 3 + 4 + 5 + 3 + 3); _time /= 60;
		dig2(_time % 60, cache.buf + 5 + 3 + 4 + 5 + 3); _time /= 60;
		dig2(_time, cache.buf + 5 + 3 + 4 + 5);

		cache.last_time = cache_time;
	}

	return
		string_t::ctor_t(sizeof(cache.buf))
			(str_t(cache.buf, sizeof(cache.buf)))
		;
}
コード例 #6
0
ファイル: print.C プロジェクト: skywalker239/lightning
void pi_t::print_app(
	out_t &out, root_t const *root, enum_table_t const &
) {
	out(str_t((char const *)root, root->size * sizeof(_size_t))); 
}
コード例 #7
0
ファイル: string.C プロジェクト: kmeaw/phantom
bool static_page_t::chunk(size_t off, str_t &str) const {
    str = str_t((char const *)NULL + off, (size_t)(-1) - off);

    return true;
}