void MMSImportPropertyDAO::update(MMSImportPropertyData *data) {
    /* do the update */
    this->getMMSDBConnection()->query(
        "update ImportProperties set Time='" + iToStr(data->getTime()) + "',"
        + "onStartUp='" + ((data->getOnStartUp())?"Y":"N") + "',"
        + "Interval='" + iToStr(data->getInterval()) + "' "
        "where ID = '" + iToStr(data->getId()) + "'");
}
void MMSImportSourceDAO::update(MMSImportSourceData *data) {
    /* do the update */
    this->getMMSDBConnection()->query(
        "update ImportSource set Name='" + data->getName() + "',"
        + "Source='" + data->getSource() + "',"
        + "LifeTime='" + iToStr(data->getLifeTime()) + "' "
        "where ID = '" + iToStr(data->getId()) + "'");
}
void MMSImportPropertyDAO::save(MMSImportPropertyData *data) {
    /* do the insert */
    this->getMMSDBConnection()->query(
        "insert into ImportProperties(PluginID,onStartUp,Time,Interval) values('"
        + iToStr(data->getPluginId()) + "','"
        + ((data->getOnStartUp())?"Y":"N") + "','"
        + iToStr(data->getTime()) + "','"
        + iToStr(data->getInterval()) + "')");
/*TODO:return over stack!!!*/
    /* set the ID */
    data->setId(this->getMMSDBConnection()->getLastInsertedID());
}
void MMSImportSourceDAO::save(MMSImportSourceData *data) {
    /* do the insert */
    this->getMMSDBConnection()->query(
        "insert into ImportSource(PluginID,Name,Source,LifeTime) values('"
        + iToStr(data->getPluginId()) + "','"
        + data->getName() + "','"
        + data->getSource() + "','"
        + iToStr(data->getLifeTime()) + "')");
/*TODO:return over stack!!!*/
    /* set the ID */
    data->setId(this->getMMSDBConnection()->getLastInsertedID());
}
MMSFBSurface *MMSFBSurfaceManager::getTemporarySurface(int w, int h) {
	if (!this->tempsuf)
		return NULL;
	this->tempsuf->lock();
	int ww, hh;
	this->tempsuf->getSize(&ww, &hh);
	if ((ww>=w)&&(hh>=h))
		return this->tempsuf;

	DEBUGMSG("MMSGUI", "the temporary surface " + iToStr(ww) + "x" + iToStr(hh) + " is to small - requested size is "
											 + iToStr(w) + "x" + iToStr(h));
	this->tempsuf->unlock();
	return NULL;
}
MMSImportPropertyData *MMSImportPropertyDAO::findImportPropertyByPlugin(MMSPluginData *plugin) {
    MMSRecordSet    rs;

    this->getMMSDBConnection()->query(
        "select * from ImportProperties where PluginID = " + iToStr(plugin->getId()),
        &rs);

    /* check if result is empty */
    if (rs.getCount()==0)
        throw MMSImportPropertyDAOError(0,"ImportProperties for PluginID " + iToStr(plugin->getId()) + " not found");

    /* fill the return data */
    return moveRecordToData(rs);
}
Example #7
0
MMSBackendPluginHandler *MMSPluginManager::getBackendPluginHandler(int pluginid) {
	vector<MMSBackendPluginHandler*>::iterator i;
	vector<MMSBackendPluginHandler*>::iterator end = this->backendPluginHandlers.end();
	for(i = this->backendPluginHandlers.begin(); i != end; ++i) {
		if((*i)->getPluginData().getId() == pluginid) {
			if((*i)->getPluginData().getType()->getName() == PT_BACKEND_PLUGIN) {
				return (*i);
			} else {
                throw MMSPluginManagerError(0,"handler for id " + iToStr(pluginid) + " is not a backend plugin");
			}
		}
	}

    throw MMSPluginManagerError(0,"backend plugin handler for id " + iToStr(pluginid) + " was not found");
}
Example #8
0
///  New tab  . . . . . . . 
void cAmp::tabNew(int m)
{
	pls->Save();
	CList* pl = new CList();
	pl->name = iToStr(++cntrPls);

	if (m==2)
	{	//  ctrl- at end
		vPlst.push_back(pl);
		plsId = vPlst.size()-1;  pls = vPlst[plsId];  }  // sel
	else
	{	//  none- after cur   alt- before cur   shift- at begin
		vPlst.insert(vPlst.begin()+ (m==-2? 0: (plsId+ (m==-1?0:1))), pl);
			// pl +-
		if (m==-2 || m==1 && plsId < plsPlId || m==-1 && plsId <= plsPlId)
		{  plsPlId++;  plsPl = vPlst[plsPlId];  }  // pl
			// sel +-
		if (plsSelId != -1)
		if (m==-2 || m==1 && plsId < plsSelId || m==-1 && plsId <= plsSelId)
		{  plsSelId++;  plsSel = vPlst[plsSelId];  }  // sel
		// cur +-
		if (m==-2)  plsId=0;  else
		if (m==1)  plsId++;		plsChg();
	}
}
Example #9
0
/**
 * Starts playing.
 *
 * If the continue flag is set it tries to continue
 * at the position where it was stopped before.
 *
 * @param   cont    if true it tries to continue at a position stopped before
 */
void MMSCDA::startPlaying(int tracknum) {
	string mrl = "cdda://" + this->device;
	if(tracknum <= titlecount && tracknum >= 1)
		mrl += "/" + iToStr(tracknum);

	this->currtitle = (tracknum >= 1 ? tracknum : 1);

#ifdef __HAVE_XINE__
	if(!this->stream) MMSAV::xineOpen(queue_cb, (void*)this);
#endif

	MMSAV::startPlaying(mrl, false);
}
Example #10
0
string &MMSDateTime::getDbDate() {
	this->dbdate = iToStr(this->yearnum) + "-"
			+ ((this->monthnum < 10) ? "0" : "") + iToStr(this->monthnum + 1) + "-"
			+ ((this->daynum < 10) ? "0" : "") + iToStr(this->daynum) + " "
			+ ((this->hour < 10) ? "0" : "") + iToStr(this->hour) + ":"
			+ ((this->minute < 10) ? "0" : "") + iToStr(this->minute) + ":"
			+ ((this->seconds < 10) ? "0" : "") + iToStr(this->seconds);

	return this->dbdate;
}
Example #11
0
void MMSCDA::checktoc() {
	int fd_cd = open(device.c_str(), O_RDONLY | O_NONBLOCK);
	if(fd_cd<0) {
		this->titlecount=-1;
		return;
	}
	struct cdrom_tochdr hdr;
	if(ioctl(fd_cd, CDROMREADTOCHDR, &hdr) == -1) {
		this->titlecount=-1;
	} else {
		DEBUGMSG("MMSMedia", "tochdr cdth_trk0: " + iToStr(hdr.cdth_trk0) + " cdth_trk1: " + iToStr(hdr.cdth_trk1));
		this->titlecount = hdr.cdth_trk1;
	}

	close(fd_cd);
}
Example #12
0
MMSImportSourceData *   MMSImportSourceDAO::findImportSourcesByID(int id) {
    MMSRecordSet                    rs;

    /* do query */
    this->getMMSDBConnection()->query(
        "select * from ImportSource where ID = " + iToStr(id),&rs);

    /* check if result is empty */
    if (rs.getCount()==0) return NULL;

    MMSImportSourceData *source = moveRecordToData(rs);


    return source;

}
Example #13
0
vector<MMSCentralPluginHandler *> MMSPluginManager::getCentralPluginHandlers(vector <MMSPluginData *> data) {
    vector<MMSCentralPluginHandler *> myhandlers;

    vector<MMSPluginData*>::iterator pdi;
    vector<MMSPluginData*>::iterator end = data.end();
    for(pdi = data.begin(); pdi != end; ++pdi) {
    	vector<MMSCentralPluginHandler*>::iterator ci;
    	vector<MMSCentralPluginHandler*>::iterator ci_end = this->centralPluginHandlers.end();
    	for(ci = this->centralPluginHandlers.begin(); ci != ci_end; ++ci) {
            if((*ci)->getPluginData().getId() == (*pdi)->getId()) {
                if((*ci)->getPluginData().getType()->getName() == PT_CENTRAL_PLUGIN) {
                	myhandlers.push_back(*ci);
                } else {
                    throw MMSPluginManagerError(0,"handler for id " + iToStr((*pdi)->getId()) + " is not a central plugin");
                }
            }
    	}
    }

    return myhandlers;
}
Example #14
0
vector<MMSOSDPluginHandler *> MMSPluginManager::getOSDPluginHandlers(vector <MMSPluginData *> data) {
    vector<MMSOSDPluginHandler *> myhandlers;

    vector<MMSPluginData*>::iterator pdi;
    vector<MMSPluginData*>::iterator end = data.end();
    for(pdi = data.begin(); pdi != end; ++pdi) {
    	vector<MMSOSDPluginHandler*>::iterator oi;
    	vector<MMSOSDPluginHandler*>::iterator oi_end = this->osdPluginHandlers.end();
    	for(oi = this->osdPluginHandlers.begin(); oi != oi_end; ++oi) {
            if((*oi)->getPluginData().getId() == (*pdi)->getId()) {
                if((*oi)->getPluginData().getType()->getName() == PT_OSD_PLUGIN) {
                	myhandlers.push_back(*oi);
                } else {
                    throw MMSPluginManagerError(0,"handler for id " + iToStr((*pdi)->getId()) + " is not a osd plugin");
                }
            }
    	}
    }

    return myhandlers;
}
Example #15
0
vector<MMSBackendPluginHandler *> MMSPluginManager::getBackendPluginHandlers(vector <MMSPluginData *> data) {
    vector<MMSBackendPluginHandler *> myhandlers;

    vector<MMSPluginData*>::iterator pdi;
    vector<MMSPluginData*>::iterator end = data.end();
    for(pdi = data.begin(); pdi != end; ++pdi) {
    	vector<MMSBackendPluginHandler*>::iterator bi;
    	vector<MMSBackendPluginHandler*>::iterator bi_end = this->backendPluginHandlers.end();
    	for(bi = this->backendPluginHandlers.begin(); bi != bi_end; ++bi) {
            if((*bi)->getPluginData().getId() == (*pdi)->getId()) {
                if((*bi)->getPluginData().getType()->getName() == PT_BACKEND_PLUGIN) {
                	myhandlers.push_back(*bi);
                } else {
                    throw MMSPluginManagerError(0,"handler for id " + iToStr((*pdi)->getId()) + " is not a backend plugin");
                }
            }
    	}
    }

    return myhandlers;
}
Example #16
0
vector<MMSImportPluginHandler *> MMSPluginManager::getImportPluginHandlers(vector <MMSPluginData *> data) {
    vector<MMSImportPluginHandler *> myhandlers;

    vector<MMSPluginData*>::iterator pdi;
    vector<MMSPluginData*>::iterator end = data.end();
    for(pdi = data.begin(); pdi != end; ++pdi) {
    	vector<MMSImportPluginHandler*>::iterator ii;
    	vector<MMSImportPluginHandler*>::iterator ii_end = this->importPluginHandlers.end();
    	for(ii = this->importPluginHandlers.begin(); ii != ii_end; ++ii) {
            if((*ii)->getPluginData().getId() == (*pdi)->getId()) {
                if((*ii)->getPluginData().getType()->getName() == PT_IMPORT_PLUGIN) {
                	myhandlers.push_back(*ii);
                } else {
                    throw MMSPluginManagerError(0,"handler for id " + iToStr((*pdi)->getId()) + " is not an import plugin");
                }
            }
    	}
    }

    return myhandlers;
}
Example #17
0
vector<MMSImportSourceData *> MMSImportSourceDAO::findImportSourcesByPlugin(MMSPluginData *plugin) {
    vector<MMSImportSourceData *>   sourceList;
    MMSRecordSet                    rs;

    /* do query */
    this->getMMSDBConnection()->query(
        "select * from ImportSource where PluginID = " + iToStr(plugin->getId()), &rs);

    /* check if result is empty */
    if (rs.getCount()==0) return sourceList;

    /* for each result record */
    do {
        /* set the values */
        MMSImportSourceData *source = new MMSImportSourceData;
        source = moveRecordToData(rs);

        /* push to list */
        sourceList.push_back(source);
    } while(rs.next() == true);

    return sourceList;
}
MMSFBSurface *MMSFBSurfaceManager::createSurface(int w, int h, MMSFBSurfacePixelFormat pixelformat, int backbuffer, bool systemonly) {
//    DFBResult               dfbres;
//    IDirectFBSurface        *dfbsurface;
//    DFBSurfaceDescription   surface_desc;
    MMSFBSurface            *surface;

#if 0
    /* searching for free surface */
    for (unsigned int i = 0; i < this->free_surfaces.size(); i++) {
        surface = free_surfaces.at(i).surface;
        MMSFBSurfaceBuffer *sb = surface->config.surface_buffer;
        if   ((surface->config.w == w) && (surface->config.h == h)
            &&(sb->pixelformat == pixelformat) && (sb->backbuffer == backbuffer)) {
            /* found, return it */
            this->free_surfaces.erase(this->free_surfaces.begin()+i);
/*TRACE
            this->used_surfaces.push_back(surface);
*/

//DEBUGOUT("reuse surface=%d,%d\n", w,h);

            return surface;
        }
        else {
            // this surface is not the right one, check the timestamp
            if (free_surfaces.at(i).insert_time < time(NULL) - 3) {
                // the surface is longer than 3 seconds in the free_surfaces list, remove it
            	// TODO: Rewrite memory handling while porting to PXA...
				surface->freeSurfaceBuffer();
                delete surface;
                this->free_surfaces.erase(this->free_surfaces.begin()+i);
            }
        }
    }
#endif

    /* create a new surface instance */
    surface = new MMSFBSurface(w, h, pixelformat, backbuffer, systemonly);
    if (!surface) {
        MMSFB_SetError(0, "cannot create new instance of MMSFBSurface");
        return NULL;
    }
    if (!surface->isInitialized()) {
    	delete surface;
    	surface = NULL;
		MMSFB_SetError(0, "cannot initialize MMSFBSurface");
		return NULL;
	}

    // get size of surface memory
    int size, bnum;
    surface->getMemSize(&size);
    surface->getNumberOfBuffers(&bnum);
    DEBUGMSG("MMSGUI", "New surface memory allocated: "
							+ iToStr(size) + " byte, "
							+ iToStr(bnum) + " buffer(s), "
							+ iToStr(size/(bnum)) + " byte for each buffer");

    // add size of the surface to my global counter
	pthread_mutex_lock(&this->surface_mem_cnt_lock);
    this->surface_mem_cnt+=size;
	pthread_mutex_unlock(&this->surface_mem_cnt_lock);
    DEBUGMSG("MMSGUI", "Sum of allocated surface memory: " + iToStr(this->surface_mem_cnt) + " byte");

    /* add to used surfaces */
/* TRACE
    this->used_surfaces.push_back(surface);
*/

    return surface;
}
void SETcom::SerializeCommon(bool w, CONFIGFILE & c)
{
	//  menu
	Param(c,w, "game.start_in_main", startInMain);
	Param(c,w, "game.in_menu", inMenu);				Param(c,w, "game.in_main", isMain);
	
	//  misc
	Param(c,w, "misc.autostart", autostart);		Param(c,w, "misc.ogredialog", ogre_dialog);
	Param(c,w, "misc.escquit", escquit);
	
	Param(c,w, "misc.language", language);			Param(c,w, "misc.mouse_capture", mouse_capture);
	Param(c,w, "misc.screenshot_png", screen_png);

	//  video
	Param(c,w, "video.windowx", windowx);			Param(c,w, "video.windowy", windowy);
	Param(c,w, "video.fullscreen", fullscreen);		Param(c,w, "video.vsync", vsync);

	Param(c,w, "video.fsaa", fsaa);
	Param(c,w, "video.buffer", buffer);				Param(c,w, "video.rendersystem", rendersystem);

	Param(c,w, "video.limit_fps", limit_fps);
	Param(c,w, "video.limit_fps_val", limit_fps_val);	Param(c,w, "video.limit_sleep", limit_sleep);


	//  graphics  ----
	Param(c,w, "graph_detail.preset", preset);
	Param(c,w, "graph_shadow.shader_mode", shader_mode);	Param(c,w, "graph_shadow.lightmap_size", lightmap_size);
	
	Param(c,w, "graph_detail.anisotropy", anisotropy);
	Param(c,w, "graph_detail.tex_filter", tex_filt);		Param(c,w, "graph_detail.tex_size", tex_size);
	Param(c,w, "graph_detail.ter_mtr", ter_mtr);			Param(c,w, "graph_detail.ter_tripl", ter_tripl);
	
	Param(c,w, "graph_detail.view_dist", view_distance);	Param(c,w, "graph_detail.ter_detail", terdetail);
	Param(c,w, "graph_detail.ter_dist", terdist);			Param(c,w, "graph_detail.road_dist", road_dist);
	
	//  water
	Param(c,w, "graph_reflect.water_reflect", water_reflect); Param(c,w, "graph_reflect.water_refract", water_refract);
	Param(c,w, "graph_reflect.water_rttsize", water_rttsize);
	
	//  shadow
	Param(c,w, "graph_shadow.dist", shadow_dist);			Param(c,w, "graph_shadow.size", shadow_size);
	Param(c,w, "graph_shadow.count",shadow_count);			Param(c,w, "graph_shadow.type", shadow_type);

	//  veget
	Param(c,w, "graph_veget.grass", grass);
	Param(c,w, "graph_veget.trees_dist", trees_dist);		Param(c,w, "graph_veget.grass_dist", grass_dist);
	Param(c,w, "graph_veget.use_imposters", use_imposters); Param(c,w, "graph_veget.imposters_only", imposters_only);


	//  hud
	Param(c,w, "hud_show.fps", show_fps);

	//  gui tracks  ---
	Param(c,w, "gui_tracks.view", tracks_view);		Param(c,w, "gui_tracks.filter", tracks_filter);
	Param(c,w, "gui_tracks.sort", tracks_sort);		Param(c,w, "gui_tracks.sortup", tracks_sortup);

	//  columns, filters
	std::string s;
	int i,v,ii,a;
	
	if (w)	//  write
		for (v=0; v < 2; ++v)
		{
			s = "";  ii = COL_VIS;
			for (i=0; i < ii; ++i)
			{
				s += iToStr(col_vis[v][i]);
				if (i < ii-1)  s += " ";
			}
			Param(c,w, "gui_tracks.columns"+iToStr(v), s);

			s = "";  ii = COL_FIL;
			for (i=0; i < ii; ++i)
			{
				s += iToStr(col_fil[v][i]);
				if (i < ii-1)  s += " ";
			}
			Param(c,w, "gui_tracks.filters"+iToStr(v), s);
		}
	else	//  read
		for (v=0; v < 2; ++v)
		{
			if (Param(c,w, "gui_tracks.columns"+iToStr(v), s))
			{	std::stringstream sc(s);
				for (i=0; i < COL_VIS; ++i)
				{	sc >> a;  col_vis[v][i] = a > 0;  }
			}

			if (Param(c,w, "gui_tracks.filters"+iToStr(v), s))
			{	std::stringstream sf(s);
				for (i=0; i < COL_FIL; ++i)
				{	sf >> a;  col_fil[v][i] = a;  }
		}	}
Example #20
0
MMSFBFont::MMSFBFont(string filename, int w, int h) :
	initialized(false),
#ifdef __HAVE_DIRECTFB__
	dfbfont(NULL),
#endif
	ft_face(NULL),
	filename(filename),
	ascender(0),
	descender(0),
	height(0) {

	// get index
	pthread_mutex_lock(&globalLock);
	MMSFBFONT_MAP::iterator it = this->index.find(this->filename);
	if (it == this->index.end()) {
		// new id
		this->index_pos++;
		this->font_id = this->index_pos;
		this->index.insert(make_pair(this->filename, this->font_id));
	}
	else {
		// use existing id
		this->font_id = it->second;
	}
	pthread_mutex_unlock(&globalLock);


    if (mmsfb->backend == MMSFB_BE_DFB) {
#ifdef  __HAVE_DIRECTFB__

		// create the dfb font
		DFBResult   		dfbres;
		DFBFontDescription 	desc;
		if (w > 0) {
			desc.flags = DFDESC_WIDTH;
			desc.width = w;
		}
		if (h > 0) {
			desc.flags = DFDESC_HEIGHT;
			desc.height = h;
		}
		if ((dfbres=mmsfb->dfb->CreateFont(mmsfb->dfb, this->filename.c_str(), &desc, (IDirectFBFont**)&this->dfbfont)) != DFB_OK) {
			MMSFB_SetError(dfbres, "IDirectFB::CreateFont(" + this->filename + ") failed");
			return;
		}
		this->initialized = true;
#endif
    }
    else {
		// init freetype library
		pthread_mutex_lock(&globalLock);
    	if (!ft_library) {
    		if (FT_Init_FreeType((FT_Library*)&this->ft_library)) {
    			MMSFB_SetError(0, "FT_Init_FreeType() failed");
    			this->ft_library = NULL;
				pthread_mutex_unlock(&globalLock);
    			return;
			}
		}

    	this->numReferences++;
		pthread_mutex_unlock(&globalLock);

    	// load the face
    	if (FT_New_Face((FT_Library)this->ft_library, this->filename.c_str(), 0, (FT_Face*)&this->ft_face)) {
    		this->ft_face = NULL;
			MMSFB_SetError(0, "FT_New_Face(" + this->filename + ") failed");
			return;
    	}

    	// select the charmap
    	if (FT_Select_Charmap((FT_Face)this->ft_face, ft_encoding_unicode)) {
    		FT_Done_Face((FT_Face)this->ft_face);
    		this->ft_face = NULL;
			MMSFB_SetError(0, "FT_Select_Charmap(ft_encoding_unicode) for " + this->filename + " failed");
			return;
    	}

    	// check requested width and height
    	if (w < 0) w = 0;
    	if (h < 0) h = 0;

#if (defined(__HAVE_OPENGL__) && defined(__HAVE_GLU__))
		if (mmsfb->bei) {
			// we create base meshes and scale up/down to glyph's destination size
			int rw = w;
			int rh = h;
			if (rw && rh) {
				float ratio = (float)rw / (float)rh;
				h = 200;
				w = h * ratio;
				if (w == h) w = 0;
				this->scale_coeff = (float)rh / (float)h;
			}
			else
			if (rh) {
				w = 0;
				h = 200;
				this->scale_coeff = (float)rh / (float)h;
			}
			else {
				w = 200;
				h = 0;
				this->scale_coeff = (float)rw / (float)w;
			}
//    		printf("coeff = %f\n", this->scale_coeff);
		}
#endif

        // set the font size
    	if (FT_Set_Char_Size((FT_Face)this->ft_face, w << 6, h << 6, 0, 0)) {
    		FT_Done_Face((FT_Face)this->ft_face);
    		this->ft_face = NULL;
			MMSFB_SetError(0, "FT_Set_Char_Size(" + iToStr(w << 6) + "," + iToStr(h << 6) + ") for " + this->filename + " failed");
			return;
    	}

    	// try to load a first glyph
    	if (FT_Load_Glyph((FT_Face)this->ft_face, FT_Get_Char_Index((FT_Face)this->ft_face, '0'), FT_LOAD_RENDER)) {
    		FT_Done_Face((FT_Face)this->ft_face);
    		this->ft_face = NULL;
			MMSFB_SetError(0, "FT_Load_Glyph('0') for " + this->filename + " failed");
			return;
    	}

    	if (((FT_Face)this->ft_face)->glyph->format != FT_GLYPH_FORMAT_BITMAP) {
    		FT_Done_Face((FT_Face)this->ft_face);
    		this->ft_face = NULL;
			MMSFB_SetError(0, "Glyph format is not FT_GLYPH_FORMAT_BITMAP for " + this->filename);
			return;
    	}

    	this->ascender = ((FT_Face)this->ft_face)->size->metrics.ascender / 64;
    	this->descender = abs(((FT_Face)this->ft_face)->size->metrics.descender / 64);
    	this->height = this->ascender + this->descender + 1;

/*
printf("asc = %d\n", this->ascender);
printf("des = %d\n", this->descender);
printf("height = %d\n", this->height);
*/

    	this->initialized = true;
    }
}
Example #21
0
STDMETHODIMP CBRecordset::Update(void)
{
	CBString strSQL(L"INSERT INTO [");
	CBString strValue;
	BOOL bFirst = TRUE;
	HRESULT hr;
	VARIANT varTemp = {VT_EMPTY};
	int i;

	CBLock l(&m_cs);

	if(m_pFields == NULL || m_pDatabase == NULL)return E_NOTIMPL;

	strSQL.Append(m_strTable);
	strSQL.Append(L"](", 2);

	for(i = 0; i < GetFieldCount(); i ++)
	{
		VARIANT* pvar = &m_arrayVariant[i];

		if(pvar->vt != VT_NULL && pvar->vt != VT_EMPTY)
		{
			if(bFirst)
			{
				strSQL.AppendChar(L'[');
				bFirst = FALSE;
			}else
			{
				strSQL.Append(L",[", 2);
				strValue.AppendChar(L',');
			}

			strSQL.Append(m_arrayFields[i]);
			strSQL.AppendChar(L']');

			if(pvar->vt == VT_DATE)
			{
				WCHAR wstr[22]; // "9999-99-99 99:99:99"
				WCHAR *pstr = wstr;
				CBDate d(pvar->date);
				SYSTEMTIME st;

				st = d;

				*pstr ++ = '\'';
				if(st.wYear != 1899 || st.wMonth != 12 || st.wDay != 30)
				{
					pstr = iToStr(st.wYear, pstr, 4);
					*pstr ++ = '-';

					pstr = iToStr(st.wMonth, pstr, 2);
					*pstr ++ = '-';

					pstr = iToStr(st.wDay, pstr, 2);
				}

				if(st.wHour || st.wMinute || st.wSecond)
				{
					if(pstr != wstr)
						*pstr ++ = ' ';

					pstr = iToStr(st.wHour, pstr, 2);
					*pstr ++ = ':';

					pstr = iToStr(st.wMinute, pstr, 2);
					*pstr ++ = ':';

					pstr = iToStr(st.wSecond, pstr, 2);
				}

				*pstr ++ = '\'';

				strValue.Append(wstr, pstr - wstr);
			}else if(pvar->vt == VT_BSTR)
			{
				BSTR TextString = pvar->bstrVal;

				CBAutoPtr<WCHAR> pszEncoded;
				UINT i, len = SysStringLen(TextString);
				UINT nPos = 0;
				WCHAR ch;

				pszEncoded.Allocate(len * 2 + 2);

				pszEncoded[nPos ++] = '\'';
				for(i = 0; i < len; i ++)
				{
					ch = TextString[i];

					if(ch == '\'')
						pszEncoded[nPos ++] = '\'';
					pszEncoded[nPos ++] = ch;
				}
				pszEncoded[nPos ++] = '\'';

				strValue.Append(pszEncoded, nPos);
			}else if(pvar->vt & VT_ARRAY)
			{
				CBVarPtr varPtr;
				CBAutoPtr<WCHAR> pszEncoded;
				static char HexChar[] = "0123456789ABCDEF";
				UINT i;

				hr = varPtr.Attach(pvar);
				if(FAILED(hr))return hr;

				pszEncoded.Allocate(varPtr.m_nSize * 2 + 3);

				pszEncoded[0] = L'x';
				pszEncoded[1] = L'\'';

				for(i = 0; i < varPtr.m_nSize; i ++)
				{
					pszEncoded[i * 2 + 2] = HexChar[varPtr.m_pData[i] >> 4];
					pszEncoded[i * 2 + 3] = HexChar[varPtr.m_pData[i] & 0xf];
				}

				pszEncoded[i * 2 + 2] = L'\'';

				strValue.Append(pszEncoded, i * 2 + 3);
			}else
			{
				hr = VariantChangeType(&varTemp, pvar, 0, VT_BSTR);
				if(FAILED(hr))return hr;

				if(varTemp.bstrVal && varTemp.bstrVal[0])
					strValue.Append(varTemp.bstrVal, SysStringLen(varTemp.bstrVal));
				else strValue.Append(L"\'\'", 2);

				VariantClear(&varTemp);
			}
		}