Example #1
0
String operator+(const String& a, const String& b)
{
    if (a.isEmpty())
        return b.copy();
    if (b.isEmpty())
        return a.copy();
    String c = a.copy();
    c += b;
    return c;
}
Example #2
0
	static void copy(String const& input, char* dest)
	{ 
		UINT32 len = (UINT32)input.length();
		input.copy(dest, len);
		dest[len] = '\0';
	}
Example #3
0
/**
* Windows specific file dialog opener
*
*  @param fileName the name of the file to save (in case @param mode is FILEMODE_SAVE)
*  otherwise ignored.
*  @param mode either FILEMODE_SAVE or FILEMODE_OPEN depending on whether
*  the dialog should be "Save as.." og "Open file.."
*  @param owner handle to the owner window
*/
String Environment::LoadFileDialog( String fileName, UInt mode, HWND owner )
{
	char Filestring[4196];
	//reset Filestring
	for ( UInt i = 0; i < 4196; i++ )
		Filestring[i] = 0;
	String returnstring;
	OPENFILENAME opf;
	LPCTSTR filter;
	Vector<char> str2;

	if ( mode == FILEMODE_OPEN )
	{
		filter = "Fits files\0*.FITS;*.FIT;*.FTS;*.IMG;*.LBL;\0\0";
		opf.lpstrDefExt = "fit";
		
		
	
	}
	else if ( mode == FILEMODE_SAVE )
	{		
		filter = "Tiff files\0*.TIFF;*.TIF\0\0";
		opf.lpstrDefExt = "tif";
		//get the position of the last '.' which defines the file extension
		Int pos = fileName.find_last_of( ".", String::npos );
		if ( pos > 0 )
			fileName = fileName.substr( 0, pos );

		fileName = fileName + ".tif";

		fileName = Environment::getFilePart( fileName );
		
		
		fileName.copy( Filestring, fileName.length(), 0 );

		
	}
	
	opf.lpstrTitle = NULL;
	opf.hwndOwner = owner;
	opf.hInstance = NULL;
	opf.lpstrFilter = filter;
	opf.lpstrCustomFilter = NULL;
	opf.nMaxCustFilter = 0L;
	opf.nFilterIndex = 1L;
	opf.lpstrFile = Filestring;	
	opf.nMaxFile = 4196;
	opf.lpstrFileTitle = NULL;
	opf.nMaxFileTitle=50;
	opf.lpstrInitialDir = NULL;

	opf.nFileOffset = NULL;
	opf.nFileExtension = NULL;
	
	opf.lpfnHook = NULL; 
	opf.lCustData = NULL;
	opf.Flags = (OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT) & ~OFN_ALLOWMULTISELECT;  
	opf.lStructSize = sizeof(OPENFILENAME);
	opf.FlagsEx = 0; 
	if ( mode == FILEMODE_OPEN )
	{
		if(GetOpenFileName(&opf))    		        
			returnstring = opf.lpstrFile;
	}
	else if ( mode == FILEMODE_SAVE )
	{
		if(GetSaveFileName(&opf))    		        
			returnstring = opf.lpstrFile;
	}
	return returnstring;
}
void WebIconDatabase::dispatchDidAddIconForPageURL(const String& pageURL)
{
    MutexLocker locker(m_notificationMutex);
    m_notificationQueue.append(pageURL.copy());
    scheduleNotificationDelivery();
}
CrossThreadCopierBase<false, String>::Type CrossThreadCopierBase<false, String>::copy(const String& str)
{
    return str.copy();
}
Example #6
0
SharedVariant::SharedVariant(CVarRef source, bool serialized,
                             bool inner /* = false */,
                             bool unserializeObj /* = false */)
    : m_count (1), m_shouldCache(false), m_flags(0) {
    ASSERT(!serialized || source.isString());

    m_type = source.getType();

    switch (m_type) {
    case KindOfBoolean:
    {
        m_data.num = source.toBoolean();
        break;
    }
    case KindOfInt64:
    {
        m_type = KindOfInt64;
        m_data.num = source.toInt64();
        break;
    }
    case KindOfDouble:
    {
        m_data.dbl = source.toDouble();
        break;
    }
    case KindOfStaticString:
    case KindOfString:
    {
        String s = source.toString();
        if (serialized) {
            m_type = KindOfObject;
            // It is priming, and there might not be the right class definitions
            // for unserialization.
            s = apc_reserialize(s);
        }
        m_data.str = s->copy(true);
        break;
    }
    case KindOfArray:
    {
        ArrayData *arr = source.getArrayData();

        if (!inner) {
            // only need to call hasInternalReference() on the toplevel array
            PointerSet seen;
            if (arr->hasInternalReference(seen)) {
                setSerializedArray();
                m_shouldCache = true;
                String s = apc_serialize(source);
                m_data.str = new StringData(s.data(), s.size(), CopyMalloc);
                break;
            }
        }

        size_t size = arr->size();
        if (arr->isVectorData()) {
            setIsVector();
            m_data.vec = new VectorData(size);
            uint i = 0;
            for (ArrayIter it(arr); !it.end(); it.next(), i++) {
                SharedVariant* val = Create(it.secondRef(), false, true,
                                            unserializeObj);
                if (val->m_shouldCache) m_shouldCache = true;
                m_data.vec->vals[i] = val;
            }
        } else {
            m_data.map = new ImmutableMap(size);
            for (ArrayIter it(arr); !it.end(); it.next()) {
                SharedVariant* key = Create(it.first(), false, true,
                                            unserializeObj);
                SharedVariant* val = Create(it.secondRef(), false, true,
                                            unserializeObj);
                if (val->m_shouldCache) m_shouldCache = true;
                m_data.map->add(key, val);
            }
        }
        break;
    }
    case KindOfUninit:
    case KindOfNull:
    {
        break;
    }
    default:
    {
        ASSERT(source.isObject());
        m_shouldCache = true;
        if (unserializeObj) {
            // This assumes hasInternalReference(seen, true) is false
            ImmutableObj* obj = new ImmutableObj(source.getObjectData());
            m_data.obj = obj;
            setIsObj();
        } else {
            String s = apc_serialize(source);
            m_data.str = new StringData(s.data(), s.size(), CopyMalloc);
        }
        break;
    }
    }
}