Exemplo n.º 1
0
void XWinIntlMgr::GetDayNames( VectorOfVString& outNames, bool inAbbreviated) const
{
	// Sunday as day 1
	static LCTYPE sTypes[] = {
		LOCALE_SDAYNAME7,
		LOCALE_SABBREVDAYNAME7,
		LOCALE_SDAYNAME1,
		LOCALE_SABBREVDAYNAME1,
		LOCALE_SDAYNAME2,
		LOCALE_SABBREVDAYNAME2,
		LOCALE_SDAYNAME3,
		LOCALE_SABBREVDAYNAME3,
		LOCALE_SDAYNAME4,
		LOCALE_SABBREVDAYNAME4,
		LOCALE_SDAYNAME5,
		LOCALE_SABBREVDAYNAME5,
		LOCALE_SDAYNAME6,
		LOCALE_SABBREVDAYNAME6,
		0,
		0
	};
	
	for( LCTYPE *pType = inAbbreviated ? &sTypes[1] : &sTypes[0] ; *pType ; pType += 2)
	{
		VString name;
		if (GetLocaleInfo( *pType, name))
			outNames.push_back( name);
	}
}
void VLocalizationTransUnitHandler::CheckPlatformTag( const VString& inTags, bool inIncludeIfTag, bool *ioExcluded)
{
	VectorOfVString tags;
	inTags.GetSubStrings( ' ', tags, false /*inReturnEmptyStrings*/, true /*inTrimSpaces*/);

	// same tags as in VContextualMenu::_AddDefaultTags
	bool mac = std::find( tags.begin(), tags.end(), CVSTR("mac")) != tags.end();
	bool win = std::find( tags.begin(), tags.end(), CVSTR("win")) != tags.end();
	bool lin = std::find( tags.begin(), tags.end(), CVSTR("linux")) != tags.end();

	if (mac || win || lin)
	{
		bool ok;
#if VERSIONMAC
		ok = mac;
#elif VERSIONWIN
		ok = win;
#elif VERSION_LINUX
		ok = lin;
#endif
		if (inIncludeIfTag && !ok)
			*ioExcluded = true;
		else if (!inIncludeIfTag && ok)
			*ioExcluded = true;
	}
}
Exemplo n.º 3
0
VError VJSONArrayReader::ToArrayString(VectorOfVString &outStrings, bool inDoAppend)
{
	if(!inDoAppend)
		outStrings.clear();

	if(fLastParseError == VE_OK)
	{
		if(!inDoAppend)
		{
			outStrings = fValues;
		}
		else if(!fValues.empty())
		{
			outStrings.insert(outStrings.end(), fValues.begin(), fValues.end());
		}
	}
	
	return fLastParseError;
}
Exemplo n.º 4
0
/*
	static
*/
void VProcess::_FetchCommandLineArguments( VectorOfVString& outArguments)
{
	VectorOfVString arguments;

#if VERSIONWIN

	int	nbArgs = 0;
	LPWSTR *tabArgs = ::CommandLineToArgvW( ::GetCommandLineW(), &nbArgs);
	for( int i = 0 ; i < nbArgs ; ++i)
	{
		arguments.push_back( VString( tabArgs[i]));
	}
	LocalFree( tabArgs);

#else

	#if VERSIONMAC
	int *argc_p = _NSGetArgc();
	char ***argv_p = _NSGetArgv();
	int argc = (argc_p == NULL) ? 0 : *argc_p;
	char **argv = (argv_p == NULL) ? NULL : *argv_p;
	#elif VERSION_LINUX
    // Postponed Linux Implementation !
	//extern int __libc_argc; jmo - Theese symbols are not available for us !
	//extern char ** __libc_argv;
	int argc = 0;
	char **argv = NULL;
	#endif
	
	VToUnicodeConverter_UTF8 converter;
	for( int i = 0 ; i < argc ; ++i)
	{
		VString s;
		converter.ConvertString( argv[i], strlen( argv[i]), NULL, s);
		arguments.push_back( s);
	}

#endif

	outArguments.swap( arguments);
}
Exemplo n.º 5
0
VError VJSONArray::GetString( VString& outString) const
{
    VError err = VE_OK;

    if (fVector.empty())
    {
        outString.Clear();
    }
    else
    {
        VectorOfVString array;
        array.resize( fVector.size());
        VectorOfVString::iterator j = array.begin();
        for( VectorType::const_iterator i = fVector.begin() ; (i != fVector.end()) && (err == VE_OK) ; ++i, ++j)
        {
            err = i->GetString( *j);
        }
        err = outString.Join( array, ',') ? VE_OK : vThrowError( VE_STRING_ALLOC_FAILED);
    }
    return err;
}
void VJSLanguageSyntaxTester::_Tokenize( XBOX::VJSParms_callStaticFunction &ioParams, void * )
{
	// We are expecting 2 JavaScript parameters:
	// - source code to tokenize
	// - extension of the fake file

	VString sourceCode, extension;

	if (ioParams.CountParams() == 2)
	{
		if (!ioParams.GetStringParam( 1, sourceCode ))	return;
		if (!ioParams.GetStringParam( 2, extension ))	return;
	}
	else
		return;

	CLanguageSyntaxComponent *languageSyntax = (CLanguageSyntaxComponent *)VComponentManager::RetainComponent( (CType)CLanguageSyntaxComponent::Component_Type );
	if (languageSyntax)
	{
		ISyntaxInterface *syntaxEngine = languageSyntax->GetSyntaxByExtension( extension );

		if (syntaxEngine)
		{
			VectorOfVString	tokens;

			syntaxEngine->GetTokensForTesting(sourceCode, tokens);

			VJSArray result( ioParams.GetContextRef() );
			VJSValue jsval(ioParams.GetContextRef());

			for (VectorOfVString::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
			{
				jsval.SetString(*it);
				result.PushValue(jsval);
			}
			ioParams.ReturnValue(result);
 		}
		languageSyntax->Release();
	}
}
void VLanguageSyntaxTesterCatalog::GetEntityModelNames(VectorOfVString& outEntityNames) const
{
	const VValueBag *catalogBag = RetainCatalogBag();
	if (catalogBag != NULL)
	{
		const VBagArray* bagModels = catalogBag->GetElements( LS_TESTER_CATALOG_DATACLASSES );
		VIndex count = (bagModels != NULL) ? bagModels->GetCount() : 0;
		for( VIndex i = 1 ; i <= count ; ++i)
		{
			const VValueBag* bagEntityModel = bagModels->GetNth(i);
			if (bagEntityModel)
			{
				VString name;
				bagEntityModel->GetString(LS_TESTER_CATALOG_NAME, name);
				outEntityNames.push_back( name);
			}
		}
	}
	ReleaseRefCountable( &catalogBag);
}
Exemplo n.º 8
0
VError VJSONWriter::StringifyArray( const VJSONArray *inArray, VString& outString)
{
	VError err = VE_OK;
	
	if (inArray == NULL)
	{
		outString = VJSONValue::sUndefinedString;
	}
	else if (inArray->IsEmpty())
	{
		outString = "[]";
	}
	else
	{
		IncrementLevel();

		VectorOfVString array;
		size_t count = inArray->GetCount();

		try
		{
			array.resize( count);
		}
		catch(...)
		{
			err = vThrowError( VE_MEMORY_FULL);
		}

		VectorOfVString::iterator j = array.begin();
		for( size_t i = 0 ; (i < count) && (err == VE_OK) ; ++i, ++j)
		{
			err = StringifyValue( (*inArray)[i], *j);
			InsertIndentString( *j);
		}

		DecrementLevel();

		if (err == VE_OK)
		{
			array.front().Insert( '[', 1);
			AppendIndentString( array.back());
			array.back().AppendUniChar( ']');
			err = outString.Join( array, ',') ? VE_OK : vThrowError( VE_STRING_ALLOC_FAILED);
		}
	}
		
	return err;
}
Exemplo n.º 9
0
void XWinIntlMgr::GetMonthNames( VectorOfVString& outNames, bool inAbbreviated) const
{
	static LCTYPE sTypes[] = {
		LOCALE_SMONTHNAME1,
		LOCALE_SABBREVMONTHNAME1,
		LOCALE_SMONTHNAME2,
		LOCALE_SABBREVMONTHNAME2,
		LOCALE_SMONTHNAME3,
		LOCALE_SABBREVMONTHNAME3,
		LOCALE_SMONTHNAME4,
		LOCALE_SABBREVMONTHNAME4,
		LOCALE_SMONTHNAME5,
		LOCALE_SABBREVMONTHNAME5,
		LOCALE_SMONTHNAME6,
		LOCALE_SABBREVMONTHNAME6,
		LOCALE_SMONTHNAME7,
		LOCALE_SABBREVMONTHNAME7,
		LOCALE_SMONTHNAME8,
		LOCALE_SABBREVMONTHNAME8,
		LOCALE_SMONTHNAME9,
		LOCALE_SABBREVMONTHNAME9,
		LOCALE_SMONTHNAME10,
		LOCALE_SABBREVMONTHNAME10,
		LOCALE_SMONTHNAME11,
		LOCALE_SABBREVMONTHNAME11,
		LOCALE_SMONTHNAME12,
		LOCALE_SABBREVMONTHNAME12,
		LOCALE_SMONTHNAME13,
		LOCALE_SABBREVMONTHNAME13,
		0,
		0
	};

	for( LCTYPE *pType = inAbbreviated ? &sTypes[1] : &sTypes[0] ; *pType ; pType += 2)
	{
		VString name;
		if (GetLocaleInfo( *pType, name))
			outNames.push_back( name);
	}
}
Exemplo n.º 10
0
VError VJSONWriter::StringifyObject( const VJSONObject *inObject, VString& outString)
{
    if (inObject == NULL)
    {
        outString = VJSONValue::sUndefinedString;
        return VE_OK;
    }

    if (std::find( fStack.begin(), fStack.end(), inObject) != fStack.end())
    {
        return vThrowError( VE_JSON_STRINGIFY_CIRCULAR);
    }

    VError err = VE_OK;

    fStack.push_back( inObject);

    if (!inObject->DoStringify( outString, *this, &err))
    {
        if (inObject->fMap.empty())
        {
            outString = "{}";
        }
        else
        {
            IncrementLevel();

            VectorOfVString array;
            array.resize( inObject->fMap.size());

            VectorOfVString::iterator j = array.begin();
            for( VJSONPropertyConstIterator i( inObject) ; i.IsValid() && (err == VE_OK) ; ++i, ++j)
            {
                err = i.GetName().GetJSONString( *j, GetOptions());
                if (err == VE_OK)
                {
                    InsertIndentString( *j);

                    VString value;
                    err = StringifyValue( i.GetValue(), value);
                    if (err == VE_OK)
                    {
                        j->AppendUniChar( ':');
                        j->AppendString( value);
                    }
                }

            }

            DecrementLevel();

            if (err == VE_OK)
            {
                array.front().Insert( '{', 1);
                AppendIndentString( array.back());
                array.back().AppendUniChar( '}');
                err = outString.Join( array, ',') ? VE_OK : vThrowError( VE_STRING_ALLOC_FAILED);
            }
        }
    }

    fStack.pop_back();

    return err;
}
Exemplo n.º 11
0
bool HTMLLexer::ConsumePossibleEntity( VString &outEntityConsumed, UniChar &outCharacterToAdd )
{
	if (!fLexerInput->HasMoreChars())	return false;
	xbox_assert( fLexerInput->PeekAtNextChar() == CHAR_AMPERSAND );

	// In HTML, escape sequences come in one of three forms:
	//	&#DDDD; (where D is decimal number)
	//	&#xHHHH; (where H is hexidecimal number -- case insensitive)
	//	&entity; (where entity is a common entity reference)
	// We've already read the ampersand, so now we want to figure out which of
	// the three cases we're dealing with.  If we don't match any of the three
	// cases, then we just assume we really had regular text and the user just
	// screwed up.

	// Consume the current character to see what sort of escape sequence we're dealing with
	fLexerInput->MoveToNextChar();	// Eat the &
	if (!fLexerInput->HasMoreChars()) {
		fLexerInput->MoveToPreviousChar();
		return false;
	}
	UniChar escapeType = fLexerInput->MoveToNextChar();
	sLONG charactersToRevert = 2;
	outEntityConsumed = "&";
	outEntityConsumed.AppendUniChar( escapeType );
	switch (escapeType) {
		case CHAR_NUMBER_SIGN: {
			// We either have a hex literal or a decimal literal following the # sign.  So we
			// will check to see which we've got and go from there
			if (!fLexerInput->HasMoreChars())	break;
			UniChar literalType = fLexerInput->MoveToNextChar();
			outEntityConsumed.AppendUniChar( literalType );
			charactersToRevert++;
			switch (literalType) {
				case CHAR_LATIN_CAPITAL_LETTER_X:
				case CHAR_LATIN_SMALL_LETTER_X: {
					// We now want to add any number of hex digits to the stream.  Though, if we go over
					// four hex digits, then we're outside of the range of any legal unicode code point, and
					// so I am going to do a hard-coded stop there.
					unsigned short value = 0;

					for (sLONG i = 0; i < 4; i++) {
						UniChar c = CHAR_CONTROL_0000;
						if (fLexerInput->HasMoreChars()) {
							c = fLexerInput->MoveToNextChar();
							charactersToRevert++;
							if (!isHexDigit( c ))	break;
							// Now we want to add the hex digit we got into our ultimate value
							value += sixteenToThePowerOf( i ) * getHexValueFromCharacter( c );
							outEntityConsumed.AppendUniChar( c );
						} else break;
					}

					// The last character needs to be a semi-colon, or else it's not a legal entity
					if (!fLexerInput->HasMoreChars()) break;
					if (fLexerInput->MoveToNextChar() != CHAR_SEMICOLON) {
						charactersToRevert++;
						break;
					}

					outEntityConsumed.AppendUniChar( ';' );

					// Add the value as a UniChar to our stream
					outCharacterToAdd = (UniChar)value;
					return true;
				} break;
				default: {
					// We want to test to see whether the character we read is a legal decimal digit.  If it
					// is, then we have a character literal.  If not, the user screwed up and we can just bail.
					if (isDecimalDigit( literalType )) {
						// We're going to put the character back just to parse it again.  It makes the logic easier
						fLexerInput->MoveToPreviousChar();

						// We know that we've got some digits we care about.  Now we need to find out how many,
						// and we'll put the cap at something sensible, like 5 characters (which can cover all of
						// the unicode code points in existence).
						unsigned short value = 0;

						for (sLONG i = 0; i < 5; i++) {
							UniChar c = CHAR_CONTROL_0000;
							if (fLexerInput->HasMoreChars()) {
								c = fLexerInput->MoveToNextChar();
								charactersToRevert++;
								if (!isDecimalDigit( c ))	break;
								// Now we want to add the decimal digit we got into our ultimate value
								value += tenToThePowerOf( i ) * (c - '0');
								outEntityConsumed.AppendUniChar( c );
							} else break;
						}

						// The last character needs to be a semi-colon, or else it's not a legal entity
						if (!fLexerInput->HasMoreChars()) break;
						if (fLexerInput->MoveToNextChar() != CHAR_SEMICOLON) {
							charactersToRevert++;
							break;
						}

						outEntityConsumed.AppendUniChar( ';' );

						// Add the value as a UniChar to our stream
						outCharacterToAdd = (UniChar)value;
						return true;
					} else break;
				} break;
			}
		} break;
		default: {
			// We found an ampersand and know it's not a numeric literal.  Now we need to see whether it's an
			// entity made to be a bit more human readable.  We're going to grab a bunch of characters from the
			// stream without actually shifting them in.  We cut them off at the semi-colon because all entities
			// must end with one to be legal.  Then, if it matches a known entity, we're set -- otherwise it's just
			// a stream of random characters.  We need a whopping nine character to be able to support &thetasym;
			VString entityName;
			fLexerInput->GetSubString( fLexerInput->GetCurrentPosition(), 9, entityName );

			// Now, let's see where the semi-colon is, and strip it off (as well as everything past it).  If we don't
			// find a semi-colon, then we know we don't have an entity
			VectorOfVString subStrs;
			if (!entityName.GetSubStrings( CHAR_SEMICOLON, subStrs ))	break;

			// The first sub string is the entity name we care about
			if (GetEntityValue( subStrs.front(), outCharacterToAdd )) {
				// We want to eat up as many characters as the entity was consuming
				VIndex size = subStrs.front().GetLength();
				for (VIndex i = 0; i < size; i++) {
					outEntityConsumed.AppendUniChar( fLexerInput->MoveToNextChar() );
				}
				return true;
			}
		} break;
	}

	// Put back the characters we screwed up on
	for (sLONG i = 0; i < charactersToRevert; i++)	fLexerInput->MoveToPreviousChar();

	return false;
}