コード例 #1
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::switchToMusic(const QString &artist, const QString &album, const QString &track)
{
    if (!m_lcdReady || !m_lcdShowMusic)
        return;

    LOG(VB_GENERAL, LOG_DEBUG, LOC + "switchToMusic");

    sendToServer("SWITCH_TO_MUSIC " + quotedString(artist) + ' '
            + quotedString(album) + ' '
            + quotedString(track));
}
コード例 #2
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::switchToChannel(const QString &channum, const QString &title,
                          const QString &subtitle)
{
    if (!m_lcdReady || !m_lcdShowChannel)
        return;

    LOG(VB_GENERAL, LOG_DEBUG, LOC + "switchToChannel");

    sendToServer("SWITCH_TO_CHANNEL " + quotedString(channum) + ' '
            + quotedString(title) + ' '
            + quotedString(subtitle));
}
コード例 #3
0
ファイル: smtpparser.cpp プロジェクト: grtodd/aox
class Address * SmtpParser::address()
{
    bool lt = false;
    if ( present( "<" ) ) {
        lt = true;
        if ( present( "@" ) ) {
            (void)domain();
            while ( present( ",@" ) )
                (void)domain();
            require( ":" );
        }
    }

    UString lp;
    if ( nextChar() == '"' )
        lp = quotedString();
    else
        lp = dotString();
    if ( !present( "@" ) )
        setError( "Address must have both localpart and domain" );
    Address * a = new Address( UString(), lp, domain() );
    if ( lt )
        require( ">" );
    return a;
}
コード例 #4
0
ファイル: jucer_ButtonDocument.cpp プロジェクト: Frongo/JUCE
//==============================================================================
void ButtonDocument::fillInGeneratedCode (GeneratedCode& code) const
{
    JucerDocument::fillInGeneratedCode (code);

    code.parentClassInitialiser = "Button (" + quotedString (code.componentName) + ")";
    code.removeCallback ("void", "paint (Graphics& g)");
}
コード例 #5
0
ファイル: derb.c プロジェクト: flwh/Alcatel_OT_985_kernel
static void printOutAlias(FILE *out,  UConverter *converter, UResourceBundle *parent, Resource r, const char *key, int32_t indent, const char *pname, UErrorCode *status) {
    static const UChar cr[] = { '\n' };
    int32_t len = 0;
    const UChar* thestr = derb_getString(&(parent->fResData), r, &len);
    UChar *string = quotedString(thestr);
    if(trunc && len > truncsize) {
        char msg[128];
        printIndent(out, converter, indent);
        sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
            (long)len, (long)truncsize/2);
        printCString(out, converter, msg, -1);
        len = truncsize;
    }
    if(U_SUCCESS(*status)) {
        static const UChar openStr[] = { 0x003A, 0x0061, 0x006C, 0x0069, 0x0061, 0x0073, 0x0020, 0x007B, 0x0020, 0x0022 }; /* ":alias { \"" */
        static const UChar closeStr[] = { 0x0022, 0x0020, 0x007D, 0x0020 }; /* "\" } " */
        printIndent(out, converter, indent);
        if(key != NULL) {
            printCString(out, converter, key, -1);
        }
        printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));
        printString(out, converter, string, len);
        printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));
        if(verbose) {
            printCString(out, converter, " // ALIAS", -1);
        }
        printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));
    } else {
        reportError(pname, status, "getting binary value");
    }
    uprv_free(string);
}
コード例 #6
0
ファイル: qgsexpression.cpp プロジェクト: lyhkop/QGIS
QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type )
{
  if ( value.isNull() )
    return QStringLiteral( "NULL" );

  switch ( type )
  {
    case QVariant::Int:
    case QVariant::LongLong:
    case QVariant::Double:
      return value.toString();

    case QVariant::Bool:
      return value.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" );

    case QVariant::List:
    {
      QStringList quotedValues;
      const QVariantList values = value.toList();
      for ( const QVariant &v : values )
      {
        quotedValues += quotedValue( v );
      }
      return QStringLiteral( "array( %1 )" ).arg( quotedValues.join( QStringLiteral( ", " ) ) );
    }

    default:
    case QVariant::String:
      return quotedString( value.toString() );
  }

}
コード例 #7
0
ファイル: sieveparser.cpp プロジェクト: aox/aox
UString SieveParser::string()
{
    whitespace();
    if ( nextChar() == '"' )
        return quotedString();
    return multiLine();
}
コード例 #8
0
	std::vector< std::string > splitStringIgnoreQuotes( std::string curStringToSplit, char delimeter /*= ' '*/, bool ignoreEmptyStrings /*= true */ )
	{
		std::vector< quotedString > m_QuotedStrings;

		std::string tmpString = "";
		bool inQuotes = false;

		for( auto iter = curStringToSplit.begin(); iter != curStringToSplit.end(); ++iter )
		{
			if( *iter == '\"' )
			{
				if( !inQuotes )
				{
					m_QuotedStrings.push_back( quotedString( tmpString ) );
					inQuotes = true;	
				}
				else
				{
					m_QuotedStrings.push_back( quotedString( tmpString, true ) );
					inQuotes = false;
				}
				tmpString = "";
			}
			else
			{
				tmpString.push_back( *iter );
			}
		}
		m_QuotedStrings.push_back( quotedString( tmpString ) );
		
		std::vector< std::string > toReturn;

		for( auto iter = m_QuotedStrings.begin(); iter != m_QuotedStrings.end(); ++iter )
		{
			if( (*iter).m_HadQuotes )
			{
				toReturn.push_back( (*iter).m_String );
			}
			else
			{
				std::vector< std::string > splitSubString = splitString( (*iter).m_String, delimeter, ignoreEmptyStrings );
				toReturn.insert( toReturn.end(), splitSubString.begin(), splitSubString.end() );
			}
		}
		
		return toReturn;
	}
コード例 #9
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::setChannelProgress(const QString &time, float value)
{
    if (!m_lcdReady || !m_lcdShowChannel)
        return;

    value = std::min(std::max(0.0f, value), 1.0f);
    sendToServer(QString("SET_CHANNEL_PROGRESS %1 %2").arg(quotedString(time))
        .arg(value));
}
コード例 #10
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::setMusicProgress(const QString &time, float value)
{
    if (!m_lcdReady || !m_lcdShowMusic)
        return;

    value = std::min(std::max(0.0f, value), 1.0f);
    sendToServer("SET_MUSIC_PROGRESS " + quotedString(time) + ' ' + 
            QString().setNum(value));    
}
コード例 #11
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::switchToVolume(const QString &app_name)
{
    if (!m_lcdReady || !m_lcdShowVolume)
        return;

    LOG(VB_GENERAL, LOG_DEBUG, LOC + "switchToVolume");

    sendToServer("SWITCH_TO_VOLUME " + quotedString(app_name));
}
コード例 #12
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::switchToMenu(QList<LCDMenuItem> &menuItems, const QString &app_name,
                       bool popMenu)
{
    if (!m_lcdReady || !m_lcdShowMenu)
        return;

    LOG(VB_GENERAL, LOG_DEBUG, LOC + "switchToMenu");

    if (menuItems.isEmpty())
        return;

    QString s = "SWITCH_TO_MENU ";

    s += quotedString(app_name);
    s += ' ' + QString(popMenu ? "TRUE" : "FALSE");


    QListIterator<LCDMenuItem> it(menuItems);
    const LCDMenuItem *curItem;

    while (it.hasNext())
    {
        curItem = &(it.next());
        s += ' ' + quotedString(curItem->ItemName());

        if (curItem->isChecked() == CHECKED)
            s += " CHECKED";
        else if (curItem->isChecked() == UNCHECKED)
            s += " UNCHECKED";
        else if (curItem->isChecked() == NOTCHECKABLE)
            s += " NOTCHECKABLE";

        s += ' ' + QString(curItem->isSelected() ? "TRUE" : "FALSE");
        s += ' ' + QString(curItem->Scroll() ? "TRUE" : "FALSE");
        QString sIndent;
        sIndent.setNum(curItem->getIndent());
        s += ' ' + sIndent;
    }

    sendToServer(s);
}
コード例 #13
0
const String quotedString (const String& s)
{
    if (s.isEmpty())
        return "String::empty";

    const int embeddedIndex = s.indexOfIgnoreCase ("%%");

    if (embeddedIndex >= 0)
    {
        String s1 (s.substring (0, embeddedIndex));
        String s2 (s.substring (embeddedIndex + 2));
        String code;

        const int closeIndex = s2.indexOf ("%%");

        if (closeIndex > 0)
        {
            code = s2.substring (0, closeIndex).trim();
            s2 = s2.substring (closeIndex + 2);
        }

        if (code.isNotEmpty())
        {
            String result;

            if (s1.isNotEmpty())
                result << quotedString (s1) << " + ";

            result << code;

            if (s2.isNotEmpty())
                result << " + " << quotedString (s2);

            return result;
        }
    }

    return "L\"" + replaceCEscapeChars (s) + "\"";
}
コード例 #14
0
ファイル: lcddevice.cpp プロジェクト: DragonStalker/mythtv
void LCD::switchToGeneric(QList<LCDTextItem> &textItems)
{
    if (!m_lcdReady || !m_lcdShowGeneric)
        return;

    LOG(VB_GENERAL, LOG_DEBUG, LOC + "switchToGeneric");

    if (textItems.isEmpty())
        return;

    QString s = "SWITCH_TO_GENERIC";

    QListIterator<LCDTextItem> it(textItems);
    const LCDTextItem *curItem;

    while (it.hasNext())
    {
        curItem = &(it.next());

        QString sRow;
        sRow.setNum(curItem->getRow());
        s += ' ' + sRow;

        if (curItem->getAlignment() == ALIGN_LEFT)
            s += " ALIGN_LEFT";
        else if (curItem->getAlignment() == ALIGN_RIGHT)
            s += " ALIGN_RIGHT";
        else if (curItem->getAlignment() == ALIGN_CENTERED)
            s += " ALIGN_CENTERED";

        s += ' ' + quotedString(curItem->getText());
        s += ' ' + quotedString(curItem->getScreen());
        s += ' ' + QString(curItem->getScroll() ? "TRUE" : "FALSE");
    }

    sendToServer(s);
}
コード例 #15
0
void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName)
{
    String params (getCreationParameters (code, component));
    const String virtualName (component->getProperties() ["virtualName"].toString());

    String s;
    s << memberVariableName << ".reset (new ";

    if (virtualName.isNotEmpty())
        s << CodeHelpers::makeValidIdentifier (virtualName, false, false, true);
    else
        s << getClassName (component);

    if (params.isEmpty())
    {
        s << "());\n";
    }
    else
    {
        StringArray lines;
        lines.addLines (params);

        params = lines.joinIntoString ("\n" + String::repeatedString (" ", s.length() + 2));

        s << " (" << params << "));\n";
    }

    s << "addAndMakeVisible (" << memberVariableName << ".get());\n";


    if (SettableTooltipClient* ttc = dynamic_cast<SettableTooltipClient*> (component))
    {
        if (ttc->getTooltip().isNotEmpty())
        {
            s << memberVariableName << "->setTooltip ("
              << quotedString (ttc->getTooltip(), code.shouldUseTransMacro())
              << ");\n";
        }
    }

    if (component->getExplicitFocusOrder() > 0)
        s << memberVariableName << "->setExplicitFocusOrder ("
          << component->getExplicitFocusOrder()
          << ");\n";

    code.constructorCode += s;
}
コード例 #16
0
QByteArray encodeRFC2047Phrase( const QString &text )
{
    /* We want to know if we can encode as ASCII. But bizarrely, Qt
       (on my system at least) doesn't have an ASCII codec. So we use
       the ISO-8859-1 superset, and check for any non-ASCII characters
       in the result. */
    QTextCodec *latin1 = QTextCodec::codecForMib(4);

    if (latin1->canEncode(text)) {
        /* Attempt to represent it as an RFC2822 'phrase' --- either a
           sequence of atoms or as a quoted-string. */
        
        if (atomPhraseRx.exactMatch(text)) {
            /* Simplest case: a sequence of atoms (not dot-atoms) */
            return latin1->fromUnicode(text);
        } else {
            /* Next-simplest representation: a quoted-string */
            QByteArray unquoted = latin1->fromUnicode(text);
            
            /* Check for non-ASCII characters. */
            for(int i = 0; i < unquoted.size(); i++) {
                char ch = unquoted[i];
                if (ch < 1 || ch >= 127) {
                    /* This string contains non-ASCII characters, so the
                       only way to represent it in a mail header is as an
                       RFC2047 encoded-word. */
                    return encodeRFC2047String(text, RFC2047_STRING_LATIN);
                }
            }

            return quotedString(unquoted);
        }
    }

    /* If the text has characters outside of the basic ASCII set, then
       it has to be encoded using the RFC2047 encoded-word syntax. */
    return encodeRFC2047String(text, RFC2047_STRING_UTF8);
}
コード例 #17
0
ファイル: AppendToFile.c プロジェクト: jgrossmann/security3
/*
	Parses the data string to make sure it is valid
*/
char *parseData(char *data) {
	int isQuoted = quotedString(data);
	if(isQuoted == -1) {
		printf("Error: Data string not closed\n");
		return NULL;
	}
	
	char *newData = NULL;
	char *temp = NULL;
	if(isQuoted) {
		temp = removeQuotes(data);
		newData = parseQuotedString(temp);
		return newData;
	}else {
		newData = parseString(data);
		if(newData == NULL) {
			return NULL;
		}
		temp = (char *) malloc((strlen(newData) + 1) * sizeof(char));
		strncpy(temp, newData, strlen(newData) + 1);
		return temp;
	}
}
コード例 #18
0
ファイル: derb.c プロジェクト: flwh/Alcatel_OT_985_kernel
static void printOutBundle(FILE *out, UConverter *converter, UResourceBundle *resource, int32_t indent, const char *pname, UErrorCode *status)
{
    static const UChar cr[] = { '\n' };

/*    int32_t noOfElements = ures_getSize(resource);*/
    int32_t i = 0;
    const char *key = ures_getKey(resource);

    switch(ures_getType(resource)) {
    case RES_STRING :
        {
            int32_t len=0;
            const UChar* thestr = ures_getString(resource, &len, status);
            UChar *string = quotedString(thestr);

            /* TODO: String truncation */
            if(trunc && len > truncsize) {
                char msg[128];
                printIndent(out, converter, indent);
                sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
                        (long)len, (long)(truncsize/2));
                printCString(out, converter, msg, -1);
                len = truncsize/2;
            }
            printIndent(out, converter, indent);
            if(key != NULL) {
                static const UChar openStr[] = { 0x0020, 0x007B, 0x0020, 0x0022 }; /* " { \"" */
                static const UChar closeStr[] = { 0x0022, 0x0020, 0x007D }; /* "\" }" */
                printCString(out, converter, key, (int32_t)uprv_strlen(key));
                printString(out, converter, openStr, (int32_t)(sizeof(openStr)/sizeof(*openStr)));
                printString(out, converter, string, len);
                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));
            } else {
                static const UChar openStr[] = { 0x0022 }; /* "\"" */
                static const UChar closeStr[] = { 0x0022, 0x002C }; /* "\"," */

                printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));
                printString(out, converter, string, (int32_t)(u_strlen(string)));
                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));
            }

            if(verbose) {
                printCString(out, converter, "// STRING", -1);
            }
            printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));

            uprv_free(string);
        }
        break;

    case RES_INT :
        {
            static const UChar openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0020, 0x007B, 0x0020 }; /* ":int { " */
            static const UChar closeStr[] = { 0x0020, 0x007D }; /* " }" */
            UChar num[20];

            printIndent(out, converter, indent);
            if(key != NULL) {
                printCString(out, converter, key, -1);
            }
            printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));
            uprv_itou(num, 20, ures_getInt(resource, status), 10, 0);
            printString(out, converter, num, u_strlen(num));
            printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));

            if(verbose) {
                printCString(out, converter, "// INT", -1);
            }
            printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));
            break;
        }
    case RES_BINARY :
        {
            int32_t len = 0;
            const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status);
            if(trunc && len > truncsize) {
                char msg[128];
                printIndent(out, converter, indent);
                sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
                        (long)len, (long)(truncsize/2));
                printCString(out, converter, msg, -1);
                len = truncsize;
            }
            if(U_SUCCESS(*status)) {
                static const UChar openStr[] = { 0x003A, 0x0062, 0x0069, 0x006E, 0x0061, 0x0072, 0x0079, 0x0020, 0x007B, 0x0020 }; /* ":binary { " */
                static const UChar closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */
                printIndent(out, converter, indent);
                if(key != NULL) {
                    printCString(out, converter, key, -1);
                }
                printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));
                for(i = 0; i<len; i++) {
                    printHex(out, converter, *data++);
                }
                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));
                if(verbose) {
                    printCString(out, converter, " // BINARY", -1);
                }
                printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));
            } else {
                reportError(pname, status, "getting binary value");
            }
        }
        break;
    case RES_INT_VECTOR :
        {
            int32_t len = 0;
            const int32_t *data = ures_getIntVector(resource, &len, status);
            if(U_SUCCESS(*status)) {
                static const UChar openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0076, 0x0065, 0x0063, 0x0074, 0x006F, 0x0072, 0x0020, 0x007B, 0x0020 }; /* ":intvector { " */
                static const UChar closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */
                UChar num[20];

                printIndent(out, converter, indent);
                if(key != NULL) {
                    printCString(out, converter, key, -1);
                }
                printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));
                for(i = 0; i < len - 1; i++) {
                    int32_t numLen =  uprv_itou(num, 20, data[i], 10, 0);
                    num[numLen++] = 0x002C; /* ',' */
                    num[numLen++] = 0x0020; /* ' ' */
                    num[numLen] = 0;
                    printString(out, converter, num, u_strlen(num));
                }
                if(len > 0) {
                    uprv_itou(num, 20, data[len - 1], 10, 0);
                    printString(out, converter, num, u_strlen(num));
                }
                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));
                if(verbose) {
                    printCString(out, converter, "// INTVECTOR", -1);
                }
                printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));
            } else {
                reportError(pname, status, "getting int vector");
            }
      }
      break;
    case RES_TABLE :
    case RES_ARRAY :
        {
            static const UChar openStr[] = { 0x007B }; /* "{" */
            static const UChar closeStr[] = { 0x007D, '\n' }; /* "}\n" */

            UResourceBundle *t = NULL;
            ures_resetIterator(resource);
            printIndent(out, converter, indent);
            if(key != NULL) {
                printCString(out, converter, key, -1);
            }
            printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));
            if(verbose) {
                if(ures_getType(resource) == RES_TABLE) {
                    printCString(out, converter, "// TABLE", -1);
                } else {
                    printCString(out, converter, "// ARRAY", -1);
                }
            }
            printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));

            if(suppressAliases == FALSE) {
              while(U_SUCCESS(*status) && ures_hasNext(resource)) {
                  t = ures_getNextResource(resource, t, status);
                  if(U_SUCCESS(*status)) {
                    printOutBundle(out, converter, t, indent+indentsize, pname, status);
                  } else {
                    reportError(pname, status, "While processing table");
                    *status = U_ZERO_ERROR;
                  }
              }
            } else { /* we have to use low level access to do this */
              Resource r = RES_BOGUS;
              for(i = 0; i < ures_getSize(resource); i++) {
                /* need to know if it's an alias */
                if(ures_getType(resource) == RES_TABLE) {
                  r = derb_getTableItem(resource->fResData.pRoot, resource->fRes, (int16_t)i);
                  key = derb_getTableKey(resource->fResData.pRoot, resource->fRes, (int16_t)i);
                } else {
                  r = derb_getArrayItem(resource->fResData.pRoot, resource->fRes, i);
                }
                if(U_SUCCESS(*status)) {
                  if(RES_GET_TYPE(r) == RES_ALIAS) {
                    printOutAlias(out, converter, resource, r, key, indent+indentsize, pname, status);
                  } else {
                    t = ures_getByIndex(resource, i, t, status);
                    printOutBundle(out, converter, t, indent+indentsize, pname, status);
                  }
                } else {
                  reportError(pname, status, "While processing table");
                  *status = U_ZERO_ERROR;
                }
              }
            }

            printIndent(out, converter, indent);
            printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));
            ures_close(t);
        }
        break;
    default:
        break;
    }

}
コード例 #19
0
ファイル: AppendToFile.c プロジェクト: jgrossmann/security3
/*
	Takes a string path and collapses it to find the
	absolute path without "." or ".."
*/
node *collapseFilePath(char *path) {
	
	int isQuoted = quotedString(path);
	if(isQuoted == -1) {
		printf("Error: File Path string not closed\n");
		return NULL;
	}
	
	node *currentNode = NULL;
	
	char *checkedStr = NULL;
	if(!isQuoted) {
		currentNode = getCurrentPath();
		checkedStr = parseString(path);
		if(checkedStr == NULL) {
			freePathReverse(currentNode);
			return NULL;
		}
		
		char *temp = (char *) malloc(strlen(checkedStr) + 8);
		if(temp == NULL) {
			printf("ERROR: No memory left to append uni to file path\n");
			freePathReverse(currentNode);
			return NULL;
		}
		strncpy(temp, checkedStr, strlen(checkedStr) + 1);
		strncat(temp, ".jg3538", 8);
		currentNode = insertNode(currentNode, temp);
		free(temp);
	}else {
	
		if(path[1] != '/') {
			currentNode = getCurrentPath();
		}
	
		path = removeQuotes(path);
		char temp[strlen(path)+1];
		strncpy(temp, path, strlen(path)+1);
		char *base = basename(temp);
		if(strncmp(base, "..", 3) == 0 && strlen(base) == 2) {
			path = (char *) realloc(path, strlen(path) + 9);
			if(path == NULL) {
				printf("ERROR: No memory left to append uni to file path\n");
				freePathReverse(currentNode);
				return NULL;
			}
			strncat(path, "/.jg3538", 8);
		}else {
			path = (char *) realloc(path, strlen(path) + 8);
			if(path == NULL) {
				printf("ERROR: No memory left to append uni to file path\n");
				freePathReverse(currentNode);
				return NULL;
			}
			strncat(path, ".jg3538", 8);
		}
		
		char *token = strtok(path, "/");
	
		while(token != NULL) {
			checkedStr = parseQuotedString(token);
		
			if(checkedStr == NULL) {
				freePathReverse(currentNode);
				free(path);
				return NULL;
			}
		
			currentNode = insertNode(currentNode, checkedStr);
			free(checkedStr);
			token = strtok(NULL, "/");
		}
		
		free(path);
	}

	while(currentNode->prev != NULL) {
		currentNode = currentNode->prev;
	}
	
	return currentNode;
}
コード例 #20
0
//==============================================================================
void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
{
    code.className = className;
    code.componentName = componentName;
    code.parentClasses = parentClasses;
    code.constructorParams = constructorParams;
    code.initialisers.addLines (variableInitialisers);

    if (! componentName.isEmpty())
        code.constructorCode << "setName (" + quotedString (componentName, false) + ");\n";

    // call these now, just to make sure they're the first two methods in the list.
    code.getCallbackCode (String::empty, "void", "paint (Graphics& g)", false)
        << "//[UserPrePaint] Add your own custom painting code here..\n//[/UserPrePaint]\n\n";

    code.getCallbackCode (String::empty, "void", "resized()", false)
        << "//[UserPreResize] Add your own custom resize code here..\n//[/UserPreResize]\n\n";

    if (ComponentLayout* l = getComponentLayout())
        l->fillInGeneratedCode (code);

    fillInPaintCode (code);

    ScopedPointer<XmlElement> e (createXml());
    jassert (e != nullptr);
    code.jucerMetadata = e->createDocument ("", false, false);

    resources.fillInGeneratedCode (code);

    code.constructorCode
        << "\n//[UserPreSize]\n"
           "//[/UserPreSize]\n";

    if (initialWidth > 0 || initialHeight > 0)
        code.constructorCode << "\nsetSize (" << initialWidth << ", " << initialHeight << ");\n";

    code.getCallbackCode (String::empty, "void", "paint (Graphics& g)", false)
        << "//[UserPaint] Add your own custom painting code here..\n//[/UserPaint]";

    code.getCallbackCode (String::empty, "void", "resized()", false)
        << "//[UserResized] Add your own custom resize handling here..\n//[/UserResized]";

    // add optional methods
    StringArray baseClasses, returnValues, methods, initialContents;
    getOptionalMethods (baseClasses, returnValues, methods, initialContents);

    for (int i = 0; i < methods.size(); ++i)
    {
        if (isOptionalMethodEnabled (methods[i]))
        {
            String baseClassToAdd (baseClasses[i]);

            if (baseClassToAdd == "Component" || baseClassToAdd == "Button")
                baseClassToAdd.clear();

            String& s = code.getCallbackCode (baseClassToAdd, returnValues[i], methods[i], false);

            if (! s.contains ("//["))
            {
                String userCommentTag ("UserCode_");
                userCommentTag += methods[i].upToFirstOccurrenceOf ("(", false, false).trim();

                s << "\n//[" << userCommentTag << "] -- Add your code here...\n"
                  << initialContents[i];

                if (initialContents[i].isNotEmpty() && ! initialContents[i].endsWithChar ('\n'))
                    s << '\n';

                s << "//[/" << userCommentTag << "]\n";
            }
        }
    }
}
コード例 #21
0
ファイル: uresb.c プロジェクト: mason105/red5cpp
void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, UErrorCode *status) {
    int32_t i = 0;
    const char *key = ures_getKey(resource);

    switch(ures_getType(resource)) {
    case URES_STRING :
        {
            int32_t len=0;
            const UChar*thestr = ures_getString(resource, &len, status);
            UChar *string = quotedString(thestr);

            /* TODO: String truncation */
            /*
            if(trunc && len > truncsize) {
                printIndent(out, indent);
                u_fprintf(out, "// WARNING: this string, size %d is truncated to %d\n", len, truncsize/2);
                len = truncsize/2;
            }
            */
            printIndent(out, indent);
            if(key != NULL) {
                u_fprintf(out, "%s { \"%S\" } ", key, string);
            } else {
                u_fprintf(out, "\"%S\",", string);
            }
            if(VERBOSE) {
                u_fprintf(out, " // STRING");
            }
            u_fprintf(out, "\n");
            free(string);
        }
        break;
    case URES_INT :
        printIndent(out, indent);
        if(key != NULL) {
            u_fprintf(out, "%s", key);
        }
        u_fprintf(out, ":int { %li } ", ures_getInt(resource, status));
        
        if(VERBOSE) {
            u_fprintf(out, " // INT");
        }
        u_fprintf(out, "\n");
        break;
    case URES_BINARY :
        {
            int32_t len = 0;
            const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status);
            if(trunc && len > truncsize) {
                printIndent(out, indent);
                u_fprintf(out, "// WARNING: this resource, size %li is truncated to %li\n", len, truncsize/2);
                len = truncsize/2;
            }
            if(U_SUCCESS(*status)) {
                printIndent(out, indent);
                if(key != NULL) {
                    u_fprintf(out, "%s", key);
                }
                u_fprintf(out, ":binary { ");
                for(i = 0; i<len; i++) {
                    printHex(out, data++);
                }
                u_fprintf(out, " }");
                if(VERBOSE) {
                    u_fprintf(out, " // BINARY");
                }
                u_fprintf(out, "\n");
                
            } else {
                reportError(status);
            }
        }
        break;
    case URES_INT_VECTOR :
      {
          int32_t len = 0;
          const int32_t *data = ures_getIntVector(resource, &len, status);
          if(U_SUCCESS(*status)) {
              printIndent(out, indent);
              if(key != NULL) {
                  u_fprintf(out, "%s", key);
              } 
              u_fprintf(out, ":intvector { ");
              for(i = 0; i<len-1; i++) {
                  u_fprintf(out, "%d, ", data[i]);
              }
              if(len > 0) {
                  u_fprintf(out, "%d ", data[len-1]);
              }
              u_fprintf(out, "}");
              if(VERBOSE) {
                  u_fprintf(out, " // INTVECTOR");
              }
              u_fprintf(out, "\n");
              
          } else {
              reportError(status);
          }
      }
      break;
    case URES_TABLE :
    case URES_ARRAY :
        {
            UResourceBundle *t = NULL;
            ures_resetIterator(resource);
            printIndent(out, indent);
            if(key != NULL) {
                u_fprintf(out, "%s ", key);
            }
            u_fprintf(out, "{");
            if(VERBOSE) {
                if(ures_getType(resource) == URES_TABLE) {
                    u_fprintf(out, " // TABLE");
                } else {
                    u_fprintf(out, " // ARRAY");
                }
            }
            u_fprintf(out, "\n");

            while(ures_hasNext(resource)) {
                t = ures_getNextResource(resource, t, status);
                printOutBundle(out, t, indent+indentsize, status);
            }

            printIndent(out, indent);
            u_fprintf(out, "}\n");
            ures_close(t);
        }
        break;
    default:
        break;
    }

}
コード例 #22
0
ファイル: sqlhighlighter.cpp プロジェクト: Mange/DBLite
SqlHighlighter::SqlHighlighter(QTextDocument *parent)
    : QSyntaxHighlighter(parent)
{
    HighlightningRule rule;

    // Set the formats
    keywordFormat.          setForeground(Qt::blue);
    functionFormat.         setForeground(Qt::darkCyan);
    numberFormat.           setForeground(Qt::red);
    singleLineCommentFormat.setForeground(Qt::darkRed);
    multiLineCommentFormat. setForeground(Qt::darkMagenta);
    quotationFormat.        setForeground(Qt::darkYellow);
    stringFormat.           setForeground(Qt::darkGreen);

    // Keywords pattern. Load keywords from resource file.
    QFile keywordsFile(":/main/highlighter/sql_keywords.txt");
    rule.format  = keywordFormat;

    if (!keywordsFile.open(QIODevice::ReadOnly))
    {
        std::cerr << "Could not open keywords file!" << std::endl;
        exit(1);
    }

    while (!keywordsFile.atEnd())
    {
        QString line = keywordsFile.readLine().replace("\n", "");
        // We should totally ignore empty lines, dude!
        if (line.length() > 0)
        {
            QString keyword = QString("\\b%1\\b").arg(line);
            rule.pattern = QRegExp(keyword, Qt::CaseInsensitive, QRegExp::RegExp2);
            highlightningRules.append(rule);
        }
    }
    keywordsFile.close();

    // Functions pattern. Load functions from resource file.
    QFile functionsFile(":/main/highlighter/sql_functions.txt");
    rule.format  = functionFormat;

    if (!functionsFile.open(QIODevice::ReadOnly))
    {
        std::cerr << "Could not open functions file!" << std::endl;
        exit(1);
    }

    while (!functionsFile.atEnd())
    {
        QString line = functionsFile.readLine().replace("\n", "");
        // We should totally ignore empty lines, dude!
        if (line.length() > 0)
        {
            QString function = QString("\\b%1\\b").arg(line);
            rule.pattern = QRegExp(function, Qt::CaseInsensitive, QRegExp::RegExp2);
            highlightningRules.append(rule);
        }
    }
    functionsFile.close();

    // Quotation pattern
    QString quotationPattern("\\b`[a-z]*`\\b");
    rule.pattern = QRegExp(quotationPattern, Qt::CaseInsensitive, QRegExp::RegExp2);
    rule.format  = quotationFormat;
    highlightningRules.append(rule);

    // Number pattern
    QString numberPattern("\\b((-)?\\d+(\\.\\d+)?)\\b");
    rule.pattern = QRegExp(numberPattern, Qt::CaseInsensitive, QRegExp::RegExp2);
    rule.format  = numberFormat;
    highlightningRules.append(rule);

    // Line comments pattern
    rule.pattern = QRegExp("^--.*", Qt::CaseInsensitive, QRegExp::RegExp2);
    rule.format  = singleLineCommentFormat;
    highlightningRules.append(rule);

    /*
    Here is a complicated regexp, which is used for detecting quoted strings.
    SQLite uses Pascal-quoting, which is double-char instead of backslash-char like this:
      C-Style:      "A \"Quoted\" String"
      Pascal-style: "A ""Quoted"" String"
    The regexp works by first looking for 0-* chars that is not a quote, and then looking for
    a double-quote and anything else after that, repeated. Here's a bit more visual:
          "  A    ""   Quoted  ""   String  "
          ^-----^ ^----------^ ^-----------^
             1st       2nd         3rd
    The first part is just like a normal string. If the string starts with a double-qoute, this
    will be empty. 2nd and 3rd uses the same part of the regexp, and starts with a double-quote
    and continues on to the first quote or to end-of-string.

    SQLite also supports so called BLOB literals, which is just like a string but with a "x" in
    front.

    Finished regexp:
       x?"([^"]*(""[^"]*)*)("|$)

       x?"(               # Opening quote. Support BLOB literal
           [^"]*          # 1st part
           (""[^"]*)*     # 2nd and 3rd part. Double-quote and then a normal repeat.
       )("|$)             # Closing quote or end of string

    Now, SQLite uses this for both single and double quoted strings, so we need to reuse it a
    bit. We therefore replace the quote with a placeholder (%1). We also need to quote some chars
    for the C++ string literal.
    */
    QString quotedString("%1([^%1]*(%1%1[^%1]*)*)(%1|$)");

    // String pattern. Double quotes and single quotes
    rule.format  = stringFormat;
    rule.pattern = QRegExp(quotedString.arg('"'), Qt::CaseInsensitive, QRegExp::RegExp2);
    highlightningRules.append(rule);
    rule.pattern = QRegExp(quotedString.arg('\''), Qt::CaseInsensitive, QRegExp::RegExp2);
    highlightningRules.append(rule);

    // Multi-Line comments pattern
    commentStartExpression = QRegExp("/\\*", Qt::CaseInsensitive, QRegExp::RegExp2);
    commentEndExpression   = QRegExp("\\*/", Qt::CaseInsensitive, QRegExp::RegExp2);
}