[GME-commit]
GMESRC/Paradigms/MetaGME/BonExtension/Rep Any.cpp,1.13,1.14
AttributeRep.cpp,1.8,1.9 Dumper.cpp,1.14,1.15 Dumper.h,1.8,1.9
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Fri Dec 31 13:51:22 CST 2004
Update of /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension/Rep
In directory braindrain:/tmp/cvs-serv1079/BonExtension/Rep
Modified Files:
Any.cpp AttributeRep.cpp Dumper.cpp Dumper.h
Log Message:
BONExt: MOF handling changed
MetaInterpreter: better handling of EnumAttribute formatting errors
CVS User: zolmol
Index: Any.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension/Rep/Any.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Any.cpp 21 Oct 2004 02:04:34 -0000 1.13
--- Any.cpp 31 Dec 2004 19:51:20 -0000 1.14
***************
*** 296,299 ****
--- 296,301 ----
/*static*/ std::string Any::parseMOFException( const std::string& exc_str)
{
+ if( exc_str.empty()) return "";
+
std::string ind0 = std::string( 2 - 1, '\t'), ind = std::string( 2, '\t'), more_ind = std::string( 2 + 1, '\t');
***************
*** 344,351 ****
/*static*/ std::string Any::parseMOFOperation( const std::string& exc_str)
{
std::string ind0 = std::string( 2 - 1, '\t'), ind = std::string( 2, '\t');
! std::string res;
! res = ind0 + exc_str;
if( exc_str.length() > 0 && exc_str[ exc_str.length() - 1 ] != '\n') res += '\n';
return res;
--- 346,361 ----
/*static*/ std::string Any::parseMOFOperation( const std::string& exc_str)
{
+ if( exc_str.empty()) return "";
+
std::string ind0 = std::string( 2 - 1, '\t'), ind = std::string( 2, '\t');
! std::string res, tabulated_exc_str;
! for( unsigned int i = 0; i < exc_str.length(); ++i)
! {
! tabulated_exc_str += exc_str[i];
! if( exc_str[i] == '\n') // covers simple '\n' and '\r\n' case as well
! tabulated_exc_str += ind;
! }
! res = ind0 + tabulated_exc_str;
if( exc_str.length() > 0 && exc_str[ exc_str.length() - 1 ] != '\n') res += '\n';
return res;
***************
*** 355,478 ****
/*static*/ std::string Any::processMOFNode( const BON::RegistryNode& rn, int ind_num)
{
! std::string mof;
!
! // exceptions
! bool any_more = true;
! for( unsigned int c = 1; any_more; ++c)
! {
! any_more = false;
!
! char bf[3];
! sprintf(bf, "%u", c);
! std::string query_str = MOFException_str + bf;
!
! BON::RegistryNode exc = rn->getChild( query_str);
! if( exc)
! {
! std::string n = exc->getName();
! n += ' ';
! }
!
! if( exc
! && 1//( exc->getStatus() == BON::RNS_Here || exc->getStatus() == BON::RNS_Meta )
! && !exc->getValue().empty())
{
! any_more = true;
! mof += parseMOFException( exc->getValue()) + "\n";
}
- else
- any_more = false;
-
- }
-
- // enums
- any_more = true;
- for( c = 1; any_more; ++c)
- {
- any_more = false;
! char bf[3];
! sprintf(bf, "%u", c);
! std::string query_str = MOFEnumeration_str + bf;
!
! BON::RegistryNode exc = rn->getChild( query_str);
! if( exc
! && 1//( exc->getStatus() == BON::RNS_Here || exc->getStatus() == BON::RNS_Meta )
! && !exc->getValue().empty())
! {
! any_more = true;
! mof += parseMOFOperation( exc->getValue()) + "\n";
! }
! else
! any_more = false;
! }
! // structures
! any_more = true;
! for( c = 1; any_more; ++c)
! {
! any_more = false;
! char bf[3];
! sprintf(bf, "%u", c);
! std::string query_str = MOFStructure_str + bf;
!
! BON::RegistryNode exc = rn->getChild( query_str);
! if( exc
! && 1//( exc->getStatus() == BON::RNS_Here || exc->getStatus() == BON::RNS_Meta )
! && !exc->getValue().empty())
! {
! any_more = true;
! mof += parseMOFOperation( exc->getValue()) + "\n";
! }
! else
! any_more = false;
! }
! // aliases
! any_more = true;
! for( c = 1; any_more; ++c)
! {
! any_more = false;
! char bf[3];
! sprintf(bf, "%u", c);
! std::string query_str = MOFAlias_str + bf;
!
! BON::RegistryNode exc = rn->getChild( query_str);
! if( exc
! && 1//( exc->getStatus() == BON::RNS_Here || exc->getStatus() == BON::RNS_Meta )
! && !exc->getValue().empty())
! {
! any_more = true;
! mof += parseMOFOperation( exc->getValue()) + "\n";
! }
! else
! any_more = false;
! }
! // operations
! any_more = true;
! for( c = 1; any_more; ++c)
! {
! any_more = false;
! char bf[3];
! sprintf(bf, "%u", c);
! std::string query_str = MOFOperation_str + bf;
!
! BON::RegistryNode exc = rn->getChild( query_str);
! if( exc
! && 1//( exc->getStatus() == BON::RNS_Here || exc->getStatus() == BON::RNS_Meta )
! && !exc->getValue().empty())
! {
! any_more = true;
! mof += parseMOFOperation( exc->getValue()) + "\n";
! }
! else
! any_more = false;
}
-
- return mof;
}
--- 365,422 ----
/*static*/ std::string Any::processMOFNode( const BON::RegistryNode& rn, int ind_num)
{
! try {
! // put the regnodes into a map, the key will be the node's name, thus ordering is provided
! std::map< std::string, BON::RegistryNode, StringLex> aliases, enums, exceptions, operations, structures;
! std::map< std::string, BON::RegistryNode, StringLex>::iterator iter, itend;
! std::set<BON::RegistryNode> all_nodes = rn->getChildren(); // inquire all children
! std::set<BON::RegistryNode>::const_iterator all_iter = all_nodes.begin();
! std::set<BON::RegistryNode>::const_iterator all_itend = all_nodes.end();
! for( ; all_iter != all_itend; ++all_iter)
{
! std::string nm = (*all_iter)->getName();
! if( Any::MOFAlias_str.compare( nm.substr( 0, Any::MOFAlias_str.length())) == 0 ) aliases[nm] = *all_iter;
! else if( Any::MOFEnumeration_str.compare( nm.substr( 0, Any::MOFEnumeration_str.length())) == 0) enums[nm] = *all_iter;
! else if( Any::MOFException_str.compare( nm.substr( 0, Any::MOFException_str.length())) == 0) exceptions[nm] = *all_iter;
! else if( Any::MOFOperation_str.compare( nm.substr( 0, Any::MOFOperation_str.length())) == 0) operations[nm] = *all_iter;
! else if( Any::MOFStructure_str.compare( nm.substr( 0, Any::MOFStructure_str.length())) == 0) structures[nm] = *all_iter;
}
! std::string mof;
! // aliases first
! iter = aliases.begin();
! itend = aliases.end();
! for( ; iter != itend; ++iter)
! mof += parseMOFOperation( iter->second->getValue()) + "\n";
! // then enums
! iter = enums.begin();
! itend = enums.end();
! for( ; iter != itend; ++iter)
! mof += parseMOFOperation( iter->second->getValue()) + "\n";
! // structures
! iter = structures.begin();
! itend = structures.end();
! for( ; iter != itend; ++iter)
! mof += parseMOFOperation( iter->second->getValue()) + "\n";
! // exceptions
! iter = exceptions.begin();
! itend = exceptions.end();
! for( ; iter != itend; ++iter)
! mof += parseMOFException( iter->second->getValue()) + "\n";
! // operations
! iter = operations.begin();
! itend = operations.end();
! for( ; iter != itend; ++iter)
! mof += parseMOFOperation( iter->second->getValue()) + "\n";
! return mof;
! } catch( ...) {
! global_vars.err << MSG_ERROR << "Some error occurred during MOF parsing.\n";
! return "";
}
}
Index: AttributeRep.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension/Rep/AttributeRep.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** AttributeRep.cpp 16 Jun 2004 18:35:02 -0000 1.8
--- AttributeRep.cpp 31 Dec 2004 19:51:20 -0000 1.9
***************
*** 12,18 ****
--- 12,20 ----
#include "globals.h"
+ #include "Dumper.h"
extern Globals global_vars;
extern int ind;
+
AttributeRep::AttributeRep( BON::FCO& ptr)
: Any( ptr)
***************
*** 40,51 ****
std::string AttributeRep::getPrompt()
{
! return m_ptr->getAttribute("Prompt")->getStringValue();
}
std::string AttributeRep::getNameToUse()
{
- /*std::string p = getPrompt();
- if ( p.empty())
- p = getName();*/
std::string p = getName();
--- 42,50 ----
std::string AttributeRep::getPrompt()
{
! return Dumper::xmlFilter( m_ptr->getAttribute("Prompt")->getStringValue());
}
std::string AttributeRep::getNameToUse()
{
std::string p = getName();
***************
*** 88,95 ****
elem2
elem3, value3
! , value4 -global_vars.error case
! elem4, -global_vars.error case
*/
! std::string items = m_ptr->getAttribute("MenuItems")->getStringValue();
items += '\n'; // like an EOF sign
--- 87,98 ----
elem2
elem3, value3
! , value4 -error case
! elem4, -error case
!
!
! using special characters like: & < > " ' is not an error any more: are replaced with the xml escape codes
*/
!
! std::string items = Dumper::xmlFilter( m_ptr->getAttribute("MenuItems")->getStringValue());
items += '\n'; // like an EOF sign
***************
*** 102,106 ****
int i = start_i, comma_i = 0;
- //TO(items);
while( i < len )
{
--- 105,108 ----
***************
*** 117,123 ****
if ( end>=st)
! m_items.push_back(items.substr( st, end - st + 1));//m_items.push_back(items.substr( start_i, comma_i - start_i));
else
m_items.push_back("Error");
// from comma_i+1 to i
--- 119,128 ----
if ( end>=st)
! m_items.push_back(items.substr( st, end - st + 1));
else
+ {
m_items.push_back("Error");
+ global_vars.err << MSG_ERROR << "Error: Enumitem #" << 1 + m_noOfItems << " of " << getPtr() << " has wrong format. (If comma is used a second value is required.)\n";
+ }
// from comma_i+1 to i
***************
*** 127,134 ****
while( end > comma_i+1 && whitespace.find( items[end]) != std::string::npos) --end; //tailing whsp
! if ( end>=st)
! m_itemsVal.push_back(items.substr( st, end - st + 1));//m_itemsVal.push_back(items.substr( comma_i + 1, i - comma_i - 1));
else
! m_items.push_back("Error");
comma_i = 0;
--- 132,142 ----
while( end > comma_i+1 && whitespace.find( items[end]) != std::string::npos) --end; //tailing whsp
! if ( end>=st && comma_i+1 < i)
! m_itemsVal.push_back(items.substr( st, end - st + 1));
else
! {
! m_itemsVal.push_back("Error");
! global_vars.err << MSG_ERROR << "Error: Enumitem #" << 1 + m_noOfItems << " of " << getPtr() << " has wrong format. (If comma is used a second value is required.)\n";
! }
comma_i = 0;
***************
*** 145,150 ****
if ( end>=st)
{
! m_items.push_back(items.substr( st, end - st + 1));//m_items.push_back(items.substr( start_i, i - start_i));
! m_itemsVal.push_back(items.substr( st, end - st + 1));//m_itemsVal.push_back(items.substr( start_i, i - start_i));
}
}
--- 153,158 ----
if ( end>=st)
{
! m_items.push_back(items.substr( st, end - st + 1));
! m_itemsVal.push_back(items.substr( st, end - st + 1));
}
}
***************
*** 161,165 ****
}
! std::string def_item = m_ptr->getAttribute("DefaultItem")->getStringValue();
bool found ( false);
--- 169,177 ----
}
! if( m_noOfItems == 0)
! global_vars.err << MSG_ERROR << "Error: No enumeration items found. Please check: " << getPtr() << ".\n";
!
! bool filled_def_item = m_ptr->getAttribute( "DefaultItem")->getStatus() >= BON::AS_Here;
! std::string def_item = Dumper::xmlFilter( m_ptr->getAttribute("DefaultItem")->getStringValue());
bool found ( false);
***************
*** 171,175 ****
}
! if (found) m_noOfDefault = i;
return true;
--- 183,190 ----
}
! if (found)
! m_noOfDefault = i;
! else if( filled_def_item)
! global_vars.err << MSG_ERROR << "Error: Default enumitem not found among enumerated items at " << getPtr() << ".\n";
return true;
***************
*** 181,191 ****
{
std::string type = a->getNameToUse();
- /*
- --modifications introduced on 2/2/2004
- std::transform ( type.begin(), type.end(), type.begin(), toupper);
- type += "_ENUM";*/
-
type += "_Type";
-
return type;
}
--- 196,200 ----
***************
*** 194,198 ****
/*virtual*/ std::string EnumAttributeRep::getMethodName()
{
- //return "getEnum" + getNameToUse();
return "get" + getNameToUse();
}
--- 203,206 ----
***************
*** 215,220 ****
for(int i = 0; i < m_noOfItems; ++i)
{
- /*mod'd on 2/2/2004
- std::string item_i = m_itemsVal[i] + "_elem";*/
std::string item_i = m_itemsVal[i] + '_' + EnumAttributeRep::enumTypeName( this);
if ( !Any::checkIfValidName( item_i))
--- 223,226 ----
***************
*** 237,242 ****
for( i = 0; i < m_noOfItems; ++i)
{
- /* mod'd on 2/2/2004
- std::string item_i = m_itemsVal[i] + "_elem";*/
std::string item_i = m_itemsVal[i] + '_' + EnumAttributeRep::enumTypeName( this);
if ( !Any::checkIfValidName( item_i))
--- 243,246 ----
***************
*** 250,254 ****
m2.m_returnValue = container->getDispNameImpl() + "::" + EnumAttributeRep::enumTypeName( this);
- //m2.m_signature = getMethodName() + "EnumType()";<-mod on 2/2/2004
m2.m_signature = getMethodName() + "()";
m2.m_container = container;
--- 254,257 ----
***************
*** 257,272 ****
return m2;
-
- /*Method m;
- //std::string src;
- src = "{\n";
- src += " return getAttribute(\"" + getName() + "\")->getStringValue();\n";
- src += "}\n\n\n";
-
- m.m_returnValue = "std::string";
- m.m_signature = getMethodName() + "()";
- m.m_container = container;
- m.m_implementation = src;
- m.m_comment = "";*/
}
--- 260,263 ----
***************
*** 353,357 ****
Method m;
std::string src;
- //src = "/*virtual*/ bool " + container->getNameImpl() + "::" + getMethodName() + "()\n";
src = CodeGen::indent(0) + "{\n";
src += CodeGen::indent(1) + "return FCOImpl::getAttribute(\"" + getName() + "\")->getBooleanValue();\n";
--- 344,347 ----
***************
*** 412,416 ****
/*virtual*/ std::string FieldAttributeRep::getMethodName()
{
- //return "getField" + getNameToUse();
return "get" + getNameToUse();
}
--- 402,405 ----
***************
*** 469,473 ****
Method m;
std::string src;
- //src = "/*virtual*/ " + getTypeStr() + " " + container->getNameImpl() + "::" + getMethodName() + "()\n";
src = CodeGen::indent(0) + "{\n";
src += CodeGen::indent(1) + "return FCOImpl::getAttribute(\"" + getName() + "\")->get" + getMethodStr() + "Value();\n";
--- 458,461 ----
Index: Dumper.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension/Rep/Dumper.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Dumper.cpp 21 Oct 2004 02:04:34 -0000 1.14
--- Dumper.cpp 31 Dec 2004 19:51:20 -0000 1.15
***************
*** 829,830 ****
--- 829,848 ----
+ /*static*/ std::string Dumper::xmlFilter( const std::string& in)
+ {
+ std::map<char, std::string> m;
+ m['&'] = "&";
+ m['>'] = ">";
+ m['<'] = "<";
+ m['"'] = """;
+ m['\''] = "'";
+
+ std::string ret;
+ for( std::string::const_iterator i = in.begin(); i != in.end(); ++i)
+ if ( m.find( *i) != m.end())
+ ret += m[*i];
+ else
+ ret += *i;
+
+ return ret;
+ }
\ No newline at end of file
Index: Dumper.h
===================================================================
RCS file: /var/lib/gme/GMESRC/Paradigms/MetaGME/BonExtension/Rep/Dumper.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Dumper.h 21 Oct 2004 02:04:34 -0000 1.8
--- Dumper.h 31 Dec 2004 19:51:20 -0000 1.9
***************
*** 21,24 ****
--- 21,26 ----
static void getGlobalUserParts( std::string& up1, std::string& up2);
+ static std::string xmlFilter( const std::string& in);
+
static bool m_bParsePrev;
static bool m_bGenInit;
More information about the GME-commit
mailing list