45 virtual HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID iid,
void ** ppvObject)
47 if (iid == __uuidof(IUnknown)
48 || iid == __uuidof(IStream)
49 || iid == __uuidof(ISequentialStream))
51 *ppvObject =
static_cast<IStream*
>(
this);
58 virtual ULONG STDMETHODCALLTYPE
AddRef(
void)
60 return (ULONG)InterlockedIncrement(&
m_refcount);
63 virtual ULONG STDMETHODCALLTYPE
Release(
void)
65 ULONG res = (ULONG) InterlockedDecrement(&
m_refcount);
73 virtual HRESULT STDMETHODCALLTYPE
Read(
void* pv, ULONG cb, ULONG* pcbRead)
86 virtual HRESULT STDMETHODCALLTYPE
Write(
void const* pv, ULONG cb, ULONG* pcbWritten)
101 virtual HRESULT STDMETHODCALLTYPE
SetSize(ULARGE_INTEGER)
106 virtual HRESULT STDMETHODCALLTYPE
CopyTo(IStream*, ULARGE_INTEGER, ULARGE_INTEGER*,
112 virtual HRESULT STDMETHODCALLTYPE
Commit(DWORD)
117 virtual HRESULT STDMETHODCALLTYPE
Revert(
void)
122 virtual HRESULT STDMETHODCALLTYPE
LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
127 virtual HRESULT STDMETHODCALLTYPE
UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
132 virtual HRESULT STDMETHODCALLTYPE
Clone(IStream **)
137 virtual HRESULT STDMETHODCALLTYPE
Seek(LARGE_INTEGER liDistanceToMove, DWORD dwOrigin,
138 ULARGE_INTEGER* lpNewFilePointer)
143 case STREAM_SEEK_SET:
144 m_pos = liDistanceToMove.LowPart;
146 case STREAM_SEEK_CUR:
147 m_pos += liDistanceToMove.LowPart;
149 case STREAM_SEEK_END:
153 return STG_E_INVALIDFUNCTION;
159 lpNewFilePointer->HighPart = 0;
160 lpNewFilePointer->LowPart =
m_pos;
163 lpNewFilePointer->HighPart = 0;
164 lpNewFilePointer->LowPart =
m_pos;
168 virtual HRESULT STDMETHODCALLTYPE
Stat(STATSTG* pStatstg, DWORD grfStatFlag)
187 std::cerr <<
"ERROR: Calling LabviewXML default constructor" << std::endl;
199 CLSCTX_INPROC_SERVER,
200 __uuidof(IXMLDOMDocument),
219 for(i=0; i<
n_lv; i++)
228 IXMLDOMNodeList *main_list = NULL, *child_list = NULL;
229 IXMLDOMNode *main_node = NULL, *child_node = NULL, *parent_node = NULL;
230 long lCount = 0, nlist;
232 BSTR tag_name = SysAllocString(
lv_tags[type]);
235 hr =
m_pxmldom->getElementsByTagName(tag_name, &main_list);
236 hr = main_list->get_length(&nlist);
240 bool is_array_element;
241 char array_name[256];
242 for(itty =
m_list.begin(); itty !=
m_list.end(); ++itty)
244 itty->second.index = 0;
246 for(i=0; i<nlist; i++)
248 is_array_element =
false;
249 hr = main_list->get_item(i, &main_node);
250 hr = main_node->get_parentNode(&parent_node);
252 hr = parent_node->get_nodeName(&bstr);
253 if (!wcscmp(L
"Array", bstr))
257 is_array_element =
true;
258 hr = parent_node->get_firstChild(&child_node);
259 child_node->get_text(&bstr);
260 wcstombs(array_name, bstr,
sizeof(array_name));
261 child_node->Release();
265 parent_node->Release();
267 hr = main_node->get_childNodes(&child_list);
268 hr = child_list->get_length(&lCount);
270 for(j=0; j< lCount; j++)
273 child_list->get_item(j, &child_node);
274 child_node->get_nodeName(&bstr);
275 if (!wcscmp(L
"Name", bstr))
279 child_node->get_text(&bstr);
280 wcstombs(name_tmp, bstr,
sizeof(name_tmp));
282 else if (!wcscmp(L
"Val", bstr))
288 child_node->get_text(&bstr);
289 std::string my_name = (is_array_element ? array_name : name_tmp);
291 item.
value.push_back(static_cast<const char*>(CW2CT(bstr)));
296 if (is_array_element)
298 itty =
m_list.find(array_name);
302 itty =
m_list.find(name_tmp);
309 bstr = SysAllocString(CT2W(item.
value[item.
index].c_str()));
315 child_node->put_text(bstr);
329 child_node->Release();
332 child_list->Release();
334 main_node->Release();
337 main_list->Release();
338 SysFreeString(tag_name);
345 sprintf(buffer,
"%ld", value);
346 return setValue(name, buffer, status);
352 sprintf(buffer,
"%ld", (
long)value);
353 return setValue(name, buffer, status);
359 sprintf(buffer,
"%u", value);
360 return setValue(name, buffer, status);
366 sprintf(buffer,
"%lu", value);
367 return setValue(name, buffer, status);
373 sprintf(buffer,
"%d", value);
374 return setValue(name, buffer, status);
381 sprintf(buffer,
"%g", value);
382 return setValue(name, buffer, status);
388 iterator =
m_list.find(name);
389 if (iterator !=
m_list.end())
391 (iterator->second).value = value;
404 static bool ignore_missing = Poco::Util::Application::instance().config().getBool(
"isisicp.ignoremissingdashboardxml",
true);
406 iterator =
m_list.find(name);
407 if (iterator !=
m_list.end())
409 (iterator->second).value[0] = value;
411 else if (!ignore_missing)
428 int stat =
getValue(name, s, status);
429 value = atof(s.c_str());
436 int stat =
getValue(name, s, status);
437 value =
static_cast<float>(atof(s.c_str()));
444 int stat =
getValue(name, s, status);
445 value = atol(s.c_str());
453 int stat =
getValue(name, s, status);
454 value = atol(s.c_str());
461 int stat =
getValue(name, s, status);
462 value = atoi(s.c_str());
469 iterator =
m_list.find(name);
470 if (iterator !=
m_list.end())
472 value = (iterator->second).value;
486 iterator =
m_list.find(name);
487 if (iterator !=
m_list.end())
489 value = (iterator->second).value[0];
505 iterator =
m_list.find(name);
506 if (iterator !=
m_list.end())
508 tstr = (iterator->second).value[0].c_str();
517 strncpy(value, tstr, max_len);
520 value[max_len-1] =
'\0';
524 for(
size_t i=strlen(tstr); i<max_len; i++)
535 IXMLDOMProcessingInstruction* pi = NULL;
536 if ( (
m_pxmldom->createProcessingInstruction(L
"xml", L
" version='1.0' encoding='ISO-8859-1'", &pi) != S_OK) || (pi == NULL) )
541 IXMLDOMElement *root_element = NULL;
542 IXMLDOMNode *out_child = NULL;
543 m_pxmldom->get_documentElement(&root_element);
545 v.punkVal = root_element;
547 if (
m_pxmldom->insertBefore(pi, v, &out_child) != S_OK)
551 if (out_child != NULL)
553 out_child->Release();
556 root_element->Release();
564 CComBSTR b(filename);
599 size_t n1 = s.find(
"<?xml");
600 size_t n2 = s.find(
"?>");
601 if (n1 != s.npos && n2 != s.npos)
603 s.erase(n1, 2+n2-n1);
619 IXMLDOMParseError *pXMLErr=NULL;
620 IXMLDOMElement *element = NULL;
621 IXMLDOMNodeList *name_list = NULL, *value_list=NULL;
622 IXMLDOMNode* node = NULL;
624 VARIANT_BOOL b_status = VARIANT_FALSE;
638 if (b_status!=VARIANT_TRUE) {
643 pXMLErr->get_line(&line);
644 pXMLErr->get_linepos(&linePos);
645 pXMLErr->get_errorCode(&hr);
670 struct stat stat_struct;
671 FILE *f = _fsopen(filename,
"rtN", _SH_DENYWR);
677 fstat(fileno(f),&stat_struct);
678 char* buffer =
new char[stat_struct.st_size+1];
679 int n = fread(buffer, 1, stat_struct.st_size, f);
684 if (buffer[i] ==
'\0')
690 CComBSTR b(n, buffer);
701 while(iterator != lvxml.
m_list.end())
703 name = iterator->first.c_str();
704 const std::vector<std::string>& value = (iterator->second).value;
int loadFromString(BSTR xml_string, DAEstatus &status)
std::string valueAsString(const char *name, DAEstatus &status)
virtual HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER)
int setValue(const char *name, const char *value, DAEstatus &status)
int loadFromFile(const char *filename, DAEstatus &status)
int addVa(int facility, int severity, int errtype, const char *format,...)
int updateFromString(const std::string &xml_string, DAEstatus &status)
int setISO8859Encoding(DAEstatus &status)
int add(DAEstatus &dstatus, bool clear)
virtual HRESULT STDMETHODCALLTYPE Clone(IStream **)
int getValue(const char *name, char *value, int max_len, bool write_null, DAEstatus &status)
static const char * lv_defaults[]
virtual HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead)
int updateFrom(const LabviewXML &lvxml, DAEstatus &status)
virtual HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
int DomFromCOM(DAEstatus &status)
int saveToString(std::string &s, DAEstatus &status)
virtual HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
static const wchar_t * lv_tags[]
virtual HRESULT STDMETHODCALLTYPE Write(void const *pv, ULONG cb, ULONG *pcbWritten)
std::pair< list_t::iterator, bool > insert_t
virtual HRESULT STDMETHODCALLTYPE Revert(void)
int saveToFile(const char *filename, DAEstatus &status)
int processElements(int type, bool reading, DAEstatus &status)
virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove, DWORD dwOrigin, ULARGE_INTEGER *lpNewFilePointer)
virtual HRESULT STDMETHODCALLTYPE Commit(DWORD)
list_t::const_iterator c_iterator_t
#define STATUS_CHECK_HR(a, status)
virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG *pStatstg, DWORD grfStatFlag)
int processAllElements(bool reading, DAEstatus &status)
std::vector< std::string > value
int toString(std::string &s)
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject)
list_t::iterator iterator_t
virtual ULONG STDMETHODCALLTYPE AddRef(void)
virtual HRESULT STDMETHODCALLTYPE CopyTo(IStream *, ULARGE_INTEGER, ULARGE_INTEGER *, ULARGE_INTEGER *)
virtual ULONG STDMETHODCALLTYPE Release(void)
IXMLDOMDocument * m_pxmldom