示例#1
0
bool GraphvizGenerator::generateCode(const ObjectModel* model)
{

  LITESQL_String fname = getOutputFilename(toLower(model->db.name +  LITESQL_L(".dot")));

  LITESQL_ofSstream os(fname.c_str());
  os <<  LITESQL_L("digraph database {") << std::endl
     <<  LITESQL_L("  node[shape=box,color=black];") << std::endl
     <<  LITESQL_L("  subgraph inheritance {") << std::endl
     <<  LITESQL_L("    edge[style=dashed,dir=forward,arrowhead=normal];") << std::endl;
    
  CodeGenerator::generate(model->objects,os,4);

  os <<  LITESQL_L("  }") << std::endl
     <<  LITESQL_L("  subgraph relations {") << std::endl
     <<  LITESQL_L("    edge[dir=forward,arrowhead=vee];") << std::endl;
  
  CodeGenerator::generate(model->relations,os,4);
  
  os <<  LITESQL_L("  }") << std::endl
     <<  LITESQL_L("}") << std::endl;

  os.close();
  return true;
}
示例#2
0
文件: string.cpp 项目: goofoo/Helium
bool startsWith(const LITESQL_String& what, const LITESQL_String& with) {
    if (what.size() < with.size())
        return false;
    if (what.substr(0, with.size()) == with)
        return true;
    return false;
}
bool ActiveRecordClassGenerator::generate(const xml::ObjectPtr& object)
{
  LITESQL_String fname = getOutputFilename(toLower(object->name + LITESQL_L(".rb")));

  LITESQL_ofSstream os(fname.c_str());
  
  
  LITESQL_String baseClass = object->parentObject.get() ? object->inherits : LITESQL_L("ActiveRecord::Base"); 
  os << LITESQL_L("class ") << object->name << LITESQL_L(" < ") << baseClass << std::endl;
  
  for (RelationHandle::sequence::const_iterator it = object->handles.begin(); it!= object->handles.end(); it++) {
    os  << ((*it)->relate->hasLimit() ? LITESQL_L("has_one") : LITESQL_L("has_many")) 
        << LITESQL_L(" :") << (*it)->name;
    
    if (!(*it)->name.empty())
      os << LITESQL_L(", :through => :") << (*it)->name;
      
      
    os  << std::endl;
    
  }
  
  os << LITESQL_L("end") << std::endl;
  os.close();
  return true;
}
示例#4
0
文件: string.cpp 项目: goofoo/Helium
LITESQL_String lstrip(const LITESQL_String& s) {
    unsigned int pos = 0;
    while (1) {
        if (isspace(s[pos]) && pos < s.size()-1)
            pos++;
        else
            break;
    }
    return s.substr(pos, s.size());
}
示例#5
0
文件: string.cpp 项目: goofoo/Helium
LITESQL_String rstrip(const LITESQL_String& s) {
    if (s.empty())
        return s;
    int pos = s.size()-1;
    while (1) {
        if (isspace(s[pos]) && pos > 0)
            pos--;
        else
            break;
    }
    return s.substr(0, pos+1);
}
示例#6
0
LITESQL_String CodeGenerator::getOutputFilename(const LITESQL_String& name) const
{
  LITESQL_String fname = getOutputDirectory();

  if (!fname.empty())
  {
#ifdef WIN32
    fname.append(LITESQL_L("\\"));
#else
    fname.append(LITESQL_L("/"));
#endif // #ifdef _WINDOWS_
  }
  fname.append(name); 
  return fname;
}
示例#7
0
文件: string.cpp 项目: goofoo/Helium
int hexToInt(const LITESQL_String& s) {
    int res = 0;
	
    for (size_t i = 0; i < s.size(); i++) {
        int multiplier = 1;
        int exp = (s.size() - 1 - i);
        while (exp-- > 0)
            multiplier *= 16;
        int ch = s[i];
        if (ch >= '0' && ch <= '9')
            res += multiplier * (ch - '0');
        else if (ch >= 'a' && ch <= 'z')
            res += multiplier * (ch - 'a');
        else if (ch >= 'A' && ch <= 'Z')
            res += multiplier * (ch - 'A');
    }
    return res;
}
示例#8
0
ODBCBackend::ODBCBackend(const LITESQL_String& connInfo) : /*db(NULL),*/ transaction(false) {
    Split params(connInfo, LITESQL_L(";"));
    LITESQL_String database;
    for (size_t i = 0; i < params.size(); i++) {
        Split param(params[i],  LITESQL_L("="));
        if (param.size() == 1)
            continue;
        if (param[0] ==  LITESQL_L("database"))
            database = param[1];
    }
    if (database.size() == 0)
        throw DatabaseError(LITESQL_L("no database-param specified"));

/*    if (ODBCBackend_open(database.c_str(), &db)) {
        throw DatabaseError(ODBCBackend_errmsg(db));
    }
*/
}
示例#9
0
文件: string.cpp 项目: goofoo/Helium
bool endsWith(const LITESQL_String& what, const LITESQL_String& with) {
    if (what.size() < with.size())
        return false;
    if (what.substr(what.size()-with.size(), what.size()) == with)
        return true;
    return false;
}
示例#10
0
文件: string.cpp 项目: goofoo/Helium
int atoi(const LITESQL_String &s) {
    return _tstoi(s.c_str());
}
示例#11
0
文件: string.cpp 项目: goofoo/Helium
LITESQL_String decapitalize(const LITESQL_String& s) {
    if (s.empty())
        return s;
    LITESQL_Char buf[2] = {tolower(s[0]), 0};
    return LITESQL_String(buf) + s.substr(1, s.size());
}
示例#12
0
文件: string.cpp 项目: goofoo/Helium
LITESQL_String toUpper(LITESQL_String s) {
    for (unsigned int i = 0; i < s.size(); i++)
        s[i] = toupper(s[i]);
    return s;	
}