[Mobies-commit] [commit] r4314 - in UDM/trunk/src/UIntWizVS: HTML/1033 Templates/1033
ksmyth at redhat3.isis.vanderbilt.edu
ksmyth at redhat3.isis.vanderbilt.edu
Wed Sep 17 12:36:17 CDT 2014
Author: ksmyth
Date: Wed Sep 17 12:36:17 2014
New Revision: 4314
Log:
UIntWizVS: use #import interfaces, support IErrorInfo, use TRANSACTION_NON_NESTED
Modified:
UDM/trunk/src/UIntWizVS/HTML/1033/Advanced.htm
UDM/trunk/src/UIntWizVS/HTML/1033/Settings.htm
UDM/trunk/src/UIntWizVS/HTML/1033/default.htm
UDM/trunk/src/UIntWizVS/Templates/1033/ComponentConfig.h
UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.cpp
UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.h
UDM/trunk/src/UIntWizVS/Templates/1033/UdmConfig.h
UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.cpp
UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.h
Modified: UDM/trunk/src/UIntWizVS/HTML/1033/Advanced.htm
==============================================================================
--- UDM/trunk/src/UIntWizVS/HTML/1033/Advanced.htm Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/HTML/1033/Advanced.htm Wed Sep 17 12:36:17 2014 (r4314)
@@ -254,7 +254,7 @@
<P CLASS="ElementSpacer"> </P>
<SPAN CLASS="sideBtnEx2">
- <INPUT CLASS="CheckBox" TYPE="checkbox" ID="REGISTER_SYSTEMWIDE" TITLE="Register the component systemwide by default (requires Administrator priviledges).">
+ <INPUT CLASS="CheckBox" TYPE="checkbox" ID="REGISTER_SYSTEMWIDE" TITLE="Register the component systemwide by default (requires Administrator priviledges).">
<DIV CLASS="itemTextCheckboxA" TITLE="Register the component systemwide by default (requires Administrator priviledges).">
<LABEL FOR="REGISTER_SYSTEMWIDE" TITLE="Register the component systemwide by default (requires Administrator priviledges).">Register systemwide</LABEL>
</DIV>
Modified: UDM/trunk/src/UIntWizVS/HTML/1033/Settings.htm
==============================================================================
--- UDM/trunk/src/UIntWizVS/HTML/1033/Settings.htm Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/HTML/1033/Settings.htm Wed Sep 17 12:36:17 2014 (r4314)
@@ -206,14 +206,8 @@
<INPUT TYPE="radio" CLASS="Radio" NAME="mgaaccess" ID="DIRECT_MGA_ACCESS" ACCESSKEY="m" TITLE="GME models will be accessed via the UDM MGA backend.">
<DIV CLASS="itemTextRadioB" TITLE="GME models will be accessed via the UDM MGA backend." ID="DIV3" >
- <LABEL FOR="UDM_LINKING_DYNAMIC" TITLE="GME models will be accessed via the UDM MGA backend." ID="LABEL4" >Direct <U>M</U>GA Access</LABEL>
+ <LABEL FOR="DIRECT_MGA_ACCESS" TITLE="GME models will be accessed via the UDM MGA backend." ID="LABEL4" >Direct <U>M</U>GA Access</LABEL>
</DIV>
- <BR>
-
- <INPUT TYPE="radio" CLASS="Radio" NAME="mgaaccess" ID="STATIC_UDM_ACCESS" ACCESSKEY="c" TITLE="Models are accessed via UDM memory backend, and the modifications do not affect the GME models.">
- <DIV CLASS="itemTextRadioB" TITLE="Models are accessed via UDM memory backend, and the modifications do not affect the GME models." ID="DIV4" >
- <LABEL FOR="STATIC_UDM_ACCESS" TITLE="Models are accessed via UDM memory backend, and the modifications do not affect the GME models." ID="LABEL5" ><U>C</U>ached model access</LABEL>
- </DIV>
</SPAN>
</TD>
</TR>
@@ -242,12 +236,6 @@
<DIV CLASS="itemTextRadioB" TITLE="UDM will be linked as a DLL to your interpreter." ID="DIV1" >
<LABEL FOR="UDM_LINKING_DYNAMIC" TITLE="UDM will be linked as a DLL to your interpreter." ID="LABEL1" ><U>D</U>ynamic linkage</LABEL>
</DIV>
- <BR>
-
- <INPUT TYPE="radio" CLASS="Radio" NAME="udmlinking" ID="UDM_LINKING_STATIC" ACCESSKEY="s" TITLE="UDM will be linked as a statically to your interpreter.">
- <DIV CLASS="itemTextRadioB" TITLE="UDM will be linked as a statically to your interpreter." ID="DIV2" >
- <LABEL FOR="UDM_LINKING_STATIC" TITLE="UDM will be linked as a statically to your interpreter." ID="LABEL2" ><U>S</U>tatic linkage</LABEL>
- </DIV>
</SPAN>
Modified: UDM/trunk/src/UIntWizVS/HTML/1033/default.htm
==============================================================================
--- UDM/trunk/src/UIntWizVS/HTML/1033/default.htm Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/HTML/1033/default.htm Wed Sep 17 12:36:17 2014 (r4314)
@@ -22,13 +22,11 @@
<!-- UDM Settings -->
<SYMBOL NAME='UDM_LINKING_DYNAMIC' TYPE=checkbox VALUE=true></SYMBOL>
- <SYMBOL NAME='UDM_LINKING_STATIC' TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME='META_LOADING_STATIC' TYPE=checkbox VALUE=true></SYMBOL>
<SYMBOL NAME='META_LOADING_DYNAMIC' TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME='DIRECT_MGA_ACCESS' TYPE=checkbox VALUE=true></SYMBOL>
- <SYMBOL NAME='STATIC_UDM_ACCESS' TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME='USE_CONSOLE' TYPE=checkbox VALUE=true></SYMBOL>
@@ -443,13 +441,9 @@
var udmLinkageDynamic = window.external.FindSymbol('UDM_LINKING_DYNAMIC');
- var udmLinkageStatic = window.external.FindSymbol('UDM_LINKING_STATIC');
if (udmLinkageDynamic) {
LINKING_SUMMARY.innerHTML = "Linking UDM Libraries <B>dynamically</B>."
}
- else if (udmLinkageStatic) {
- LINKING_SUMMARY.innerHTML = "Linking UDM Libraries <B>statically</B>."
- }
else {
LINKING_SUMMARY.innerHTML = "<B>Unkown</B> UDM linkage, please check UDM Settings page!"
}
@@ -469,13 +463,9 @@
var directMGAAccess = window.external.FindSymbol('DIRECT_MGA_ACCESS');
- var staticUDMAccess = window.external.FindSymbol('STATIC_UDM_ACCESS');
if (directMGAAccess) {
ACCESS_SUMMARY.innerHTML = "Access method: <B>Direct MGA Access</B>."
}
- else if (staticUDMAccess) {
- ACCESS_SUMMARY.innerHTML = "Access method: <B>Cached UDM Access</B> (Read only)."
- }
else {
ACCESS_SUMMARY.innerHTML = "<B>Unkown</B> access method, please check UDM Settings page!"
}
Modified: UDM/trunk/src/UIntWizVS/Templates/1033/ComponentConfig.h
==============================================================================
--- UDM/trunk/src/UIntWizVS/Templates/1033/ComponentConfig.h Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/Templates/1033/ComponentConfig.h Wed Sep 17 12:36:17 2014 (r4314)
@@ -66,14 +66,10 @@
// not defined: #define BON_ICON_SUPPORT
[!endif]
-[!if BON_CUSTOM_TRANSACTIONS]
-#define BON_CUSTOM_TRANSACTIONS
-[!else]
-// not defined: #define BON_CUSTOM_TRANSACTIONS
-[!endif]
-
[!if REGISTER_SYSTEMWIDE]
#define REGISTER_SYSTEMWIDE
[!else]
// not defined: #define REGISTER_SYSTEMWIDE
[!endif]
+
+#define GME_COMPONENT_ISUPPORTERRORINFO
Modified: UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.cpp
==============================================================================
--- UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.cpp Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.cpp Wed Sep 17 12:36:17 2014 (r4314)
@@ -9,13 +9,30 @@
#include <ComHelp.h>
#include <GMECOM.h>
#include "ComponentConfig.h"
+#ifndef __INTELLISENSE__
+#import "progid:Mga.MgaMetaFolder" no_implementation auto_search no_namespace no_search_namespace
+#import "progid:Mga.MgaFolders" no_implementation auto_search no_namespace no_search_namespace
+#import "progid:Mga.MgaMetaFolder" implementation_only auto_search no_namespace no_search_namespace
+#import "progid:Mga.MgaFolders" implementation_only auto_search no_namespace no_search_namespace
+#import "libid:0ADEEC71-D83A-11D3-B36B-005004CC8592" no_implementation auto_search no_namespace no_search_namespace
+#import "libid:0ADEEC71-D83A-11D3-B36B-005004CC8592" implementation_only auto_search no_namespace no_search_namespace
+#else
+// IntelliSense has a known issue with the above lines.
+// http://connect.microsoft.com/VisualStudio/feedback/details/533526/vc-2010-intellisense-import-directive-using-libid-does-not-work
+#ifdef _DEBUG
+// If IntelliSense reports "Cannot open source file", compile then reopen the project
+#include "Debug\Meta.tlh"
+#include "Debug\Mga.tlh"
+#else
+#include "Release\Meta.tlh"
+#include "Release\Mga.tlh"
+#endif
+#endif
+
#include "RawComponent.h"
-[!if USE_CONSOLE]
// Console
#include "UdmConsole.h"
-[!endif]
-
// Udm includes
#include "UdmBase.h"
@@ -35,6 +52,8 @@
#include "UdmApp.h"
#include "UdmConfig.h"
+__declspec(noreturn) void ThrowComError(HRESULT hr, LPOLESTR err); // from ComHelp.cpp
+
// this method is called after all the generic initialization is done
// this should be empty, unless application-specific initialization is needed
STDMETHODIMP RawComponent::Initialize(struct IMgaProject *) {
@@ -50,7 +69,7 @@
return InvokeEx(gme, focus, selected, parvar);
#else
if(interactive) {
- AfxMessageBox("This component does not support the obsolete invoke mechanism");
+ AfxMessageBox(_T("This component does not support the obsolete invoke mechanism"));
}
return E_MGA_NOT_SUPPORTED;
#endif
@@ -63,8 +82,8 @@
// This is the main component method for interpereters and plugins.
// May als be used in case of invokeable addons
-STDMETHODIMP RawComponent::InvokeEx( IMgaProject *project, IMgaFCO *currentobj,
- IMgaFCOs *selectedobjs, long param)
+STDMETHODIMP RawComponent::InvokeEx( IMgaProject *project, IMgaFCO *currentobj,
+ IMgaFCOs *selectedobjs, long param)
{
// Calling the user's initialization function
if(CUdmApp::Initialize())
@@ -81,18 +100,15 @@
GMEConsole::Console::SetupConsole(ccpProject);
[!endif]
- if(interactive)
- {
CComBSTR projname;
CComBSTR focusname = "<nothing>";
CComPtr<IMgaTerritory> terr;
- COMTHROW(ccpProject->CreateTerritory(NULL, &terr));
// Setting up Udm
#ifdef _DYNAMIC_META
#ifdef _DYNAMIC_META_DOM
// Loading the meta for the project
- UdmDom::DomDataNetwork ddnMeta(Uml::diagram);
+ UdmDom::DomDataNetwork ddnMeta(Uml::diagram);
Uml::Diagram theUmlDiagram;
// Opening the XML meta of the project
@@ -137,153 +153,88 @@
#endif
try
{
- // Opening backend
- dngBackend.OpenExisting(ccpProject, Udm::CHANGES_LOST_DEFAULT);
-
-
- CComPtr<IMgaFCO> ccpFocus(currentobj);
- Udm::Object currentObject;
- if(ccpFocus)
+ ccpProject->BeginTransactionInNewTerr(TRANSACTION_NON_NESTED); // could also be TRANSACTION_GENERAL
+ try
{
- currentObject=dngBackend.Gme2Udm(ccpFocus);
- }
-
- std::set<Udm::Object> selectedObjects;
+ // Opening backend
+ dngBackend.OpenExisting(ccpProject, Udm::CHANGES_LOST_DEFAULT, true);
- CComPtr<IMgaFCOs> ccpSelObject(selectedobjs);
- MGACOLL_ITERATE(IMgaFCO,ccpSelObject){
- Udm::Object currObj;
- if(MGACOLL_ITER)
+ CComPtr<IMgaFCO> ccpFocus(currentobj);
+ Udm::Object currentObject;
+ if(ccpFocus)
{
- currObj=dngBackend.Gme2Udm(MGACOLL_ITER);
+ currentObject=dngBackend.Gme2Udm(ccpFocus);
}
- selectedObjects.insert(currObj);
- }MGACOLL_ITERATE_END;
-#ifdef _ACCESS_MEMORY
- // Creating Cache
- #ifdef _DYNAMIC_META
- Udm::SmartDataNetwork dnsCacheBackend(udmDataDiagram);
- #else
- Udm::SmartDataNetwork dnsCacheBackend(META_NAMESPACE::diagram);
- #endif
-
- const Uml::Class & safeType = Uml::SafeTypeContainer::GetSafeType(dngBackend.GetRootObject().type());
-
- dnsCacheBackend.CreateNew("tmp.mem","",safeType, Udm::CHANGES_LOST_DEFAULT);
-
- Udm::Object nullObject(&Udm::_null);
- UdmUtil::copy_assoc_map copyAssocMap;
- copyAssocMap[currentObject]=nullObject; // currentObject may be null object
-
- std::set<Udm::Object>::iterator p_CurrSelObject;
- for(p_CurrSelObject=selectedObjects.begin();
- p_CurrSelObject!=selectedObjects.end();p_CurrSelObject++)
- {
- std::pair<Udm::Object const, Udm::Object> item(*p_CurrSelObject, nullObject);
+ std::set<Udm::Object> selectedObjects;
- std::pair<UdmUtil::copy_assoc_map::iterator, bool> insRes = copyAssocMap.insert(item);
+ if (selectedobjs) {
+ CComPtr<IMgaFCOs> ccpSelObject(selectedobjs);
- if (!insRes.second)
- {
- assert(false);
- }
+ MGACOLL_ITERATE(IMgaFCO,ccpSelObject){
+ Udm::Object currObj;
+ if(MGACOLL_ITER)
+ {
+ currObj=dngBackend.Gme2Udm(MGACOLL_ITER);
+ }
+ selectedObjects.insert(currObj);
+ }MGACOLL_ITERATE_END;
+ }
+ // Calling the main entry point
+ CUdmApp::UdmMain(&dngBackend,currentObject,selectedObjects,param);
+ // Closing backend
+ dngBackend.CloseWithUpdate();
+ ccpProject->CommitTransaction();
}
-
- // Copying from GME to memory
- UdmUtil::CopyObjectHierarchy(
- dngBackend.GetRootObject().__impl(),
- dnsCacheBackend.GetRootObject().__impl(),
- &dnsCacheBackend,
- copyAssocMap);
-
- // Searching for focus object
- Udm::Object currentObjectCache;
- UdmUtil::copy_assoc_map::iterator currObject = copyAssocMap.find(currentObject);
- if (currObject != copyAssocMap.end()) // It is in the map
+ catch (...)
{
- currentObjectCache=currObject->second;
+ ccpProject->raw_AbortTransaction();
+ throw;
}
-
-
- // Searching for selected objects
- std::set<Udm::Object> selectedObjectsCache;
-
- for( p_CurrSelObject=selectedObjects.begin();
- p_CurrSelObject!=selectedObjects.end();p_CurrSelObject++)
- {
- Udm::Object object;
- UdmUtil::copy_assoc_map::iterator currSelObjectIt = copyAssocMap.find(*p_CurrSelObject);
- if (currSelObjectIt != copyAssocMap.end()) // It is in the map
- {
- object=currSelObjectIt->second;
- selectedObjectsCache.insert(object);
- }
- }
-
-
- // Closing GME backend
- dngBackend.CloseNoUpdate();
-
- // Calling the main entry point
- CUdmApp::UdmMain(&dnsCacheBackend,currentObjectCache,selectedObjectsCache,param);
- // Close cache backend
- dnsCacheBackend.CloseNoUpdate();
-
-#else
- // Calling the main entry point
- CUdmApp::UdmMain(&dngBackend,currentObject,selectedObjects,param);
- // Closing backend
- dngBackend.CloseWithUpdate();
-#endif
-
}
catch(udm_exception &exc)
{
-#ifdef _META_ACCESS_MEMORY
- dnCacheBackend.CloseNoUpdate();
-#endif
// Close GME Backend (we may close it twice, but GmeDataNetwork handles it)
dngBackend.CloseNoUpdate();
-[!if USE_CONSOLE]
- GMEConsole::Console::Error::writeLine(exc.what());
-[!else]
- AfxMessageBox(exc.what());
-[!endif]
- return S_FALSE;
+ ThrowComError(E_FAIL, GMEConsole::BSTRFromUTF8(exc.what()));
}
- }
}
catch (udm_exception& e)
{
- ccpProject->AbortTransaction();
+[!if USE_CONSOLE]
+ GMEConsole::Console::gmeoleapp = 0;
+[!endif]
+ ThrowComError(E_FAIL, GMEConsole::BSTRFromUTF8(e.what()));
+ }
+ catch (_com_error& e)
+ {
+[!if USE_CONSOLE]
GMEConsole::Console::gmeoleapp = 0;
- std::string msg = "Udm exception: ";
- msg += e.what();
- AfxMessageBox(msg.c_str());
- return E_FAIL;
+[!endif]
+ throw;
}
catch(...)
{
- ccpProject->AbortTransaction();
+[!if USE_CONSOLE]
GMEConsole::Console::gmeoleapp = 0;
- // This can be a problem with the GME Console, so we display it in a message box
- AfxMessageBox("An unexpected error has occurred during the interpretation process.");
- return E_FAIL;
+[!endif]
+ ThrowComError(E_FAIL, _bstr_t(L"An unexpected error has occurred during the interpretation process."));
}
+[!if USE_CONSOLE]
GMEConsole::Console::gmeoleapp = 0;
+[!endif]
return S_OK;
}
// GME currently does not use this function
// you only need to implement it if other invokation mechanisms are used
-STDMETHODIMP RawComponent::ObjectsInvokeEx( IMgaProject *project, IMgaObject *currentobj, IMgaObjects *selectedobjs, long param) {
+STDMETHODIMP RawComponent::ObjectsInvokeEx( IMgaProject *project, IMgaObject *currentobj, IMgaObjects *selectedobjs, long param) {
if(interactive) {
- AfxMessageBox("Tho ObjectsInvoke method is not implemented");
+ AfxMessageBox(_T("The ObjectsInvoke method is not implemented"));
}
return E_MGA_NOT_SUPPORTED;
}
@@ -304,16 +255,14 @@
// these two functions are the main
STDMETHODIMP RawComponent::GlobalEvent(globalevent_enum event) {
if(event == GLOBALEVENT_UNDO) {
- AfxMessageBox("UNDO!!");
+ AfxMessageBox(_T("Undo"));
}
return S_OK;
}
STDMETHODIMP RawComponent::ObjectEvent(IMgaObject * obj, unsigned long eventmask, VARIANT v) {
if(eventmask & OBJEVENT_CREATED) {
- CComBSTR objID;
- COMTHROW(obj->get_ID(&objID));
- AfxMessageBox( "Object created! ObjID: " + CString(objID));
+ AfxMessageBox(_T("Object created: ObjID=") + obj->ID);
}
return S_OK;
}
Modified: UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.h
==============================================================================
--- UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.h Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/Templates/1033/RawComponent.h Wed Sep 17 12:36:17 2014 (r4314)
@@ -1,8 +1,5 @@
#ifndef RAWCOMPONENT_H
#define RAWCOMPONENT_H
-
-#include "Mga.h"
-
// Declaration of the main RAW COM component interface class
Modified: UDM/trunk/src/UIntWizVS/Templates/1033/UdmConfig.h
==============================================================================
--- UDM/trunk/src/UIntWizVS/Templates/1033/UdmConfig.h Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/Templates/1033/UdmConfig.h Wed Sep 17 12:36:17 2014 (r4314)
@@ -21,10 +21,6 @@
#define META_PATH "[!output VALID_META_PATH]"
[!endif]
-[!if STATIC_UDM_ACCESS]
- #define _ACCESS_MEMORY
-[!endif]
-
[!if VALID_HEADER_TO_INCLUDE]
#include "[!output HEADER_TO_INCLUDE]"
Modified: UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.cpp
==============================================================================
--- UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.cpp Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.cpp Wed Sep 17 12:36:17 2014 (r4314)
@@ -1,44 +1,45 @@
#include "stdafx.h"
+#include "Gme.h"
#include "UdmConsole.h"
#include "UdmBase.h"
namespace GMEConsole
{
- CComBSTR BSTRFromUTF8(const std::string& utf8)
- {
- if (utf8.empty())
- return CComBSTR();
-
- // Fail if an invalid input character is encountered
- const DWORD conversionFlags = MB_ERR_INVALID_CHARS;
-
- const int utf16Length = ::MultiByteToWideChar(CP_UTF8, conversionFlags, utf8.data(), utf8.length(), NULL, 0);
- if (utf16Length == 0)
- {
- DWORD error = ::GetLastError();
-
- throw udm_exception(
- (error == ERROR_NO_UNICODE_TRANSLATION) ?
- "Invalid UTF-8 sequence found in input string." :
- "Can't get length of UTF-16 string (MultiByteToWideChar failed).");
- }
-
- BSTR utf16 = SysAllocStringByteLen(NULL, utf16Length*2);
- if (utf16 == NULL)
- throw std::bad_alloc();
-
- if (!::MultiByteToWideChar(CP_UTF8, 0, utf8.data(), utf8.length(), utf16, utf16Length))
- {
- DWORD error = ::GetLastError();
- SysFreeString(utf16);
- throw udm_exception("Can't convert string from UTF-8 to UTF-16 (MultiByteToWideChar failed).");
- }
-
- CComBSTR ret;
- ret.m_str = utf16;
- return ret;
- }
+ CComBSTR BSTRFromUTF8(const std::string& utf8)
+ {
+ if (utf8.empty())
+ return CComBSTR();
+
+ // Fail if an invalid input character is encountered
+ const DWORD conversionFlags = MB_ERR_INVALID_CHARS;
+
+ const int utf16Length = ::MultiByteToWideChar(CP_UTF8, conversionFlags, utf8.data(), utf8.length(), NULL, 0);
+ if (utf16Length == 0)
+ {
+ DWORD error = ::GetLastError();
+
+ throw udm_exception(
+ (error == ERROR_NO_UNICODE_TRANSLATION) ?
+ "Invalid UTF-8 sequence found in input string." :
+ "Can't get length of UTF-16 string (MultiByteToWideChar failed).");
+ }
+
+ BSTR utf16 = SysAllocStringByteLen(NULL, utf16Length*2);
+ if (utf16 == NULL)
+ throw std::bad_alloc();
+
+ if (!::MultiByteToWideChar(CP_UTF8, 0, utf8.data(), utf8.length(), utf16, utf16Length))
+ {
+ DWORD error = ::GetLastError();
+ SysFreeString(utf16);
+ throw udm_exception("Can't convert string from UTF-8 to UTF-16 (MultiByteToWideChar failed).");
+ }
+
+ CComBSTR ret;
+ ret.m_str = utf16;
+ return ret;
+ }
CComPtr<IGMEOLEApp> Console::gmeoleapp=0;
@@ -68,4 +69,56 @@
}
}
}
+
+ void Console::writeLine(const std::string& message, msgtype_enum type)
+ {
+ if (gmeoleapp == 0) {
+ switch (type) {
+ case MSG_NORMAL:
+ case MSG_INFO:
+ case MSG_WARNING:
+ printf("%s", message.c_str());
+ break;
+ case MSG_ERROR:
+ fprintf(stderr, "%s", message.c_str());
+ break;
+ }
+ } else {
+ if(S_OK != gmeoleapp->ConsoleMessage(CComBSTR(message.length(), message.c_str()), type))
+ throw udm_exception("Could not write to GME console.");
+ }
+ }
+
+ void Console::writeLine(const std::wstring& message, msgtype_enum type)
+ {
+ if (gmeoleapp == 0) {
+ switch (type) {
+ case MSG_NORMAL:
+ case MSG_INFO:
+ case MSG_WARNING:
+ wprintf(L"%s", message.c_str());
+ break;
+ case MSG_ERROR:
+ fwprintf(stderr, L"%s", message.c_str());
+ break;
+ }
+ } else {
+ if(S_OK != gmeoleapp->ConsoleMessage(CComBSTR(message.length(), message.c_str()), type))
+ throw udm_exception("Could not write to GME console.");
+ }
+ }
+
+ void Console::setContents(const std::string& contents)
+ {
+ if (gmeoleapp != 0)
+ if(S_OK != gmeoleapp->put_ConsoleContents( CComBSTR(contents.length(),contents.c_str()) ))
+ throw udm_exception("Could not set the contents of GME console.");
+ }
+ void Console::setContents(const std::wstring& contents)
+ {
+ if (gmeoleapp != 0)
+ if(S_OK != gmeoleapp->put_ConsoleContents( CComBSTR(contents.length(),contents.c_str()) ))
+ throw udm_exception("Could not set the contents of GME console.");
+ }
+
}
\ No newline at end of file
Modified: UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.h
==============================================================================
--- UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.h Wed Aug 27 12:41:25 2014 (r4313)
+++ UDM/trunk/src/UIntWizVS/Templates/1033/UdmConsole.h Wed Sep 17 12:36:17 2014 (r4314)
@@ -6,13 +6,9 @@
#include <string>
#include "GMEVersion.h"
-#if GME_VERSION_MAJOR >= 11
-#include "Gme.h"
-#endif
-
namespace GMEConsole
{
- CComBSTR BSTRFromUTF8(const std::string & utf8);
+ CComBSTR BSTRFromUTF8(const std::string & utf8);
class Console
{
@@ -36,43 +32,9 @@
}
static void SetupConsole(CComPtr<IMgaProject> project) { setupConsole(project); }
- static void writeLine(const std::string& message, msgtype_enum type)
- {
- if (gmeoleapp == 0) {
- switch (type) {
- case MSG_NORMAL:
- case MSG_INFO:
- case MSG_WARNING:
- printf("%s", message.c_str());
- break;
- case MSG_ERROR:
- fprintf(stderr, "%s", message.c_str());
- break;
- }
- } else {
- if(S_OK != gmeoleapp->ConsoleMessage(CComBSTR(message.length(), message.c_str()), type))
- throw udm_exception("Could not write to GME console.");
- }
- }
+ static void writeLine(const std::string& message, msgtype_enum type);
- static void writeLine(const std::wstring& message, msgtype_enum type)
- {
- if (gmeoleapp == 0) {
- switch (type) {
- case MSG_NORMAL:
- case MSG_INFO:
- case MSG_WARNING:
- wprintf(L"%s", message.c_str());
- break;
- case MSG_ERROR:
- fwprintf(stderr, L"%s", message.c_str());
- break;
- }
- } else {
- if(S_OK != gmeoleapp->ConsoleMessage(CComBSTR(message.length(), message.c_str()), type))
- throw udm_exception("Could not write to GME console.");
- }
- }
+ static void writeLine(const std::wstring& message, msgtype_enum type);
static void clear()
{
@@ -80,18 +42,8 @@
gmeoleapp->put_ConsoleContents(NULL);
}
- static void setContents(const std::string& contents)
- {
- if (gmeoleapp != 0)
- if(S_OK != gmeoleapp->put_ConsoleContents( CComBSTR(contents.length(),contents.c_str()) ))
- throw udm_exception("Could not set the contents of GME console.");
- }
- static void setContents(const std::wstring& contents)
- {
- if (gmeoleapp != 0)
- if(S_OK != gmeoleapp->put_ConsoleContents( CComBSTR(contents.length(),contents.c_str()) ))
- throw udm_exception("Could not set the contents of GME console.");
- }
+ static void setContents(const std::string& contents);
+ static void setContents(const std::wstring& contents);
class Error
{
More information about the Mobies-commit
mailing list