예제 #1
0
void MojLogEngine::updateLoggerLevel(MojLogger* logger)
{
	MojAssertMutexLocked(m_mutex);
	MojAssert(logger);

	bool matched = false;
	const MojChar* loggerName = logger->name();
	MojSize loggerLen = MojStrLen(loggerName);

	for (LevelMap::ConstIterator i = m_levels.begin(); i != m_levels.end(); ++i) {
		const MojChar* confName = i.key().data();
		MojSize confLen = i.key().length();

		if (loggerLen >= confLen &&
			!MojStrNCmp(loggerName, confName, confLen) &&
			(loggerName[confLen] == _T('\0') || loggerName[confLen] == _T('.')))
		{
			// update the level, but keep iterating because there may be a longer match
			logger->level(i.value());
			matched = true;
		}
	}
	if (!matched) {
		// default to default
		logger->level(m_defaultLogger.level());
	}
}
예제 #2
0
파일: MojSock.cpp 프로젝트: webOS-ports/db8
MojErr MojSockAddr::fromPath(const MojChar* path)
{
    MojAssert(path);

    MojSockAddrUnT addr;
    MojZero(&addr, sizeof(addr));

    if (MojStrLen(path) > (sizeof(addr.sun_path) - 1))
        MojErrThrow(MojErrPathTooLong);
    MojStrCpy(addr.sun_path, path);

    addr.sun_family = MOJ_PF_LOCAL;
    fromAddr((MojSockAddrT*) &addr, sizeof(addr));

    return MojErrNone;
}
예제 #3
0
MojErr MojDbQuery::toObject(MojObjectVisitor& visitor) const
{
	MojErr err = visitor.beginObject();
	MojErrCheck(err);

	if (!m_selectProps.empty()) {
		err = visitor.propName(SelectKey, MojStrLen(SelectKey));
		MojErrCheck(err);
		err = visitor.beginArray();
		MojErrCheck(err);
		for (StringSet::ConstIterator i = m_selectProps.begin(); i != m_selectProps.end(); i++) {
			err = visitor.stringValue(*i, i->length());
			MojErrCheck(err);
		}
		err = visitor.endArray();
		MojErrCheck(err);
	}

	err = visitor.stringProp(FromKey, m_fromType);
	MojErrCheck(err);

	if (!m_whereClauses.empty()) {
		err = appendClauses(visitor, WhereKey, m_whereClauses);
		MojErrCheck(err);
	}

	if (!m_filterClauses.empty()) {
		err = appendClauses(visitor, WhereKey, m_whereClauses);
		MojErrCheck(err);
	}

	if (!m_orderProp.empty()) {
		err = visitor.stringProp(OrderByKey, m_orderProp);
		MojErrCheck(err);
	}

	if (!m_distinct.empty()) {
		err = visitor.stringProp(DistinctKey, m_distinct);
		MojErrCheck(err);
	}

	if (m_desc) {
		err = visitor.boolProp(DescKey, true);
		MojErrCheck(err);
	}

	if (m_limit != LimitDefault) {
		err = visitor.intProp(LimitKey, m_limit);
		MojErrCheck(err);
	}

	if (!m_page.empty()) {
		MojObject obj;
		err = m_page.toObject(obj);
		MojErrCheck(err);
		err = visitor.objectProp(PageKey, obj);
		MojErrCheck(err);
	}

	err = visitor.endObject();
	MojErrCheck(err);

	return MojErrNone;
}