void PatternLayout::setConversionPattern(const std::string& conversionPattern) throw(ConfigureFailure) {
#ifdef LOG4CPP_HAVE_SSTREAM 
        std::istringstream conversionStream(conversionPattern);
#else
        std::istrstream conversionStream(conversionPattern.c_str());
#endif
        std::string literal;

        char ch;
        PatternLayout::PatternComponent* component = NULL;
        int minWidth = 0;
        size_t maxWidth = 0;
        clearConversionPattern();
        while (conversionStream.get(ch)) {
            if (ch == '%') {
                // readPrefix;
                {
                    char ch2;
                    conversionStream.get(ch2);
                    if ((ch2 == '-') || ((ch2 >= '0') && (ch2 <= '9'))) {
                        conversionStream.putback(ch2);
                        conversionStream >> minWidth;
                        conversionStream.get(ch2);
                    } 
                    if (ch2 == '.') {
                        conversionStream >> maxWidth;
                    } else {
Esempio n. 2
0
void PatternLoggingLayout::setPattern(const std::string& sPattern)
{
    std::istringstream conversionStream(sPattern);
    std::string sLiteral;

    char ch;
    PatternLoggingLayout::PatternComponent* component = NULL;
    size_t minWidth = 0;
    size_t maxWidth = 0;
    clearPattern();
    while (conversionStream.get(ch)) 
    {
        if (ch == '%') 
        {
            // readPrefix;
            {
                char ch2;
                conversionStream.get(ch2);
                if ((ch2 == '-') || ((ch2 >= '0') && (ch2 <= '9'))) 
                {
                    conversionStream.putback(ch2);
                    conversionStream >> minWidth;
                    conversionStream.get(ch2);
                } 
                if (ch2 == '.') 
                {
                    conversionStream >> maxWidth;
                } 
Esempio n. 3
0
std::string AbstractHost::getNextPackageID()
{
	std::ostringstream conversionStream("");
	conversionStream<<nextPackageID;
	nextPackageID++;
	
	return conversionStream.str();
}
double ConfigurationManager::valueAsDouble(std::string value, double defaultValue)
{
	double result = defaultValue;
	std::stringstream conversionStream(value);
	
	conversionStream >> result;
	
	return result;
}
long long ConfigurationManager::valueAsLongLong(std::string value, long long defaultValue)
{
	long long result = defaultValue;
	std::stringstream conversionStream(value);
	
	conversionStream >> result; 
	
	return result;
}