<commit_before>#include <QStringList>
#include <QString>
#include <QDebug>

#include "wd.h"
#include "font.h"
#include "../base/state.h"

// ---------------------------------------------------------------------
Font::Font(string s)
{

  if (s=="fixfont") {
    font=config.Font;
    return;
  }
  angle=0;
  QString face, sizestyle;
  int bold=0,italic=0,strikeout=0,underline=0;
  float size=0;
  QString textstring = (QString::fromUtf8 (s.c_str())).simplified();
  if (textstring.startsWith("\"")) {
    QStringList ss=textstring.split("\"",QString::SkipEmptyParts);
    if (ss.length()>0) {
      face = ss[0];
      if (ss.length()>1) {
        sizestyle = ss[1];
        QStringList ss1=sizestyle.split(" ",QString::SkipEmptyParts);
        for (int j = 0; j < ss1.length(); j++) {
          if (ss1[j]=="bold") bold = 1;
          else if (ss1[j]=="italic") italic = 1;
          else if (ss1[j]=="underline") underline = 1;
          else if (ss1[j]=="strikeout") strikeout = 1;
          else if (ss1[j].mid(0,5)=="angle") angle = c_strtoi(q2s(ss1[j].mid(5)));
          else size = (float) c_strtod(q2s(ss1[j]));
        }
      }
    }
  } else {
    QStringList ss=textstring.split(" ",QString::SkipEmptyParts);
    if (ss.length()>0) {
      face = ss[0];
      if (ss.length()>1) {
        for (int j = 1; j < ss.length(); j++) {
          if (ss[j]=="bold") bold = 1;
          else if (ss[j]=="italic") italic = 1;
          else if (ss[j]=="underline") underline = 1;
          else if (ss[j]=="strikeout") strikeout = 1;
          else if (ss[j].mid(0,5)=="angle") angle = c_strtoi(q2s(ss[j].mid(5)));
          else size = (float) c_strtod(q2s(ss[j]));
        }
      }
    }
  }

//  qDebug() << "font: " + face + ",size=" + QString::number(size) + ",bold=" + QString::number(bold) + ",italic=" + QString::number(italic) + ",strikeout=" + QString::number(strikeout) + ",underline=" + QString::number(underline) + ",angle=" + QString::number(angle) ;
  font = QFont (face);
  if (0.0!=size) font.setPointSizeF((size>0.0)?size:-size);
  font.setBold(bold);
  font.setItalic(italic);
  font.setStrikeOut(strikeout);
  font.setUnderline(underline);
}

// ---------------------------------------------------------------------
Font::Font(string s,int size10, bool bold, bool italic, bool strikeout, bool underline, int angle10)
{
  angle=angle10;
  QString face = QString::fromUtf8 (s.c_str());
  font = QFont (face);
  font.setPointSizeF(size10/10);
  font.setBold(bold);
  font.setItalic(italic);
  font.setStrikeOut(strikeout);
  font.setUnderline(underline);
}
<commit_msg>support font alias of profont<commit_after>#include <QApplication>
#include <QStringList>
#include <QString>
#include <QDebug>

#include "wd.h"
#include "font.h"
#include "../base/state.h"

// ---------------------------------------------------------------------
Font::Font(string s)
{
  if (s=="fixfont") {
    font=config.Font;
    return;
  } else if (s=="profont") {
    font=QApplication::font();
    return;
  }
  angle=0;
  QString face, sizestyle;
  int bold=0,italic=0,strikeout=0,underline=0;
  float size=0;
  QString textstring = (QString::fromUtf8 (s.c_str())).simplified();
  if (textstring.startsWith("\"")) {
    QStringList ss=textstring.split("\"",QString::SkipEmptyParts);
    if (ss.length()>0) {
      face = ss[0];
      if (ss.length()>1) {
        sizestyle = ss[1];
        QStringList ss1=sizestyle.split(" ",QString::SkipEmptyParts);
        for (int j = 0; j < ss1.length(); j++) {
          if (ss1[j]=="bold") bold = 1;
          else if (ss1[j]=="italic") italic = 1;
          else if (ss1[j]=="underline") underline = 1;
          else if (ss1[j]=="strikeout") strikeout = 1;
          else if (ss1[j].mid(0,5)=="angle") angle = c_strtoi(q2s(ss1[j].mid(5)));
          else size = (float) c_strtod(q2s(ss1[j]));
        }
      }
    }
  } else {
    QStringList ss=textstring.split(" ",QString::SkipEmptyParts);
    if (ss.length()>0) {
      face = ss[0];
      if (ss.length()>1) {
        for (int j = 1; j < ss.length(); j++) {
          if (ss[j]=="bold") bold = 1;
          else if (ss[j]=="italic") italic = 1;
          else if (ss[j]=="underline") underline = 1;
          else if (ss[j]=="strikeout") strikeout = 1;
          else if (ss[j].mid(0,5)=="angle") angle = c_strtoi(q2s(ss[j].mid(5)));
          else size = (float) c_strtod(q2s(ss[j]));
        }
      }
    }
  }

//  qDebug() << "font: " + face + ",size=" + QString::number(size) + ",bold=" + QString::number(bold) + ",italic=" + QString::number(italic) + ",strikeout=" + QString::number(strikeout) + ",underline=" + QString::number(underline) + ",angle=" + QString::number(angle) ;
  font = QFont (face);
  if (0.0!=size) font.setPointSizeF((size>0.0)?size:-size);
  font.setBold(bold);
  font.setItalic(italic);
  font.setStrikeOut(strikeout);
  font.setUnderline(underline);
}

// ---------------------------------------------------------------------
Font::Font(string s,int size10, bool bold, bool italic, bool strikeout, bool underline, int angle10)
{
  angle=angle10;
  QString face = QString::fromUtf8 (s.c_str());
  font = QFont (face);
  font.setPointSizeF(size10/10);
  font.setBold(bold);
  font.setItalic(italic);
  font.setStrikeOut(strikeout);
  font.setUnderline(underline);
}
<|endoftext|>


<commit_before>
#include <QBoxLayout>
#include <QMenuBar>
#include <QSignalMapper>

#include <sstream>  //include this to use string streams

#include "wd.h"
#include "font.h"
#include "cmd.h"
#include "form.h"
#include "pane.h"
#include "tabs.h"
#include "child.h"
#include "isigraph2.h"
#include "menus.h"
#ifdef QT_OPENGL
#include "opengl2.h"
#endif
#include "../base/state.h"
#include "../base/term.h"

// ---------------------------------------------------------------------
Form::Form(string s, string p, string loc, QWidget *parent) : QWidget (parent)
{
  Q_UNUSED(parent);
  id=s;
  child=0;
  evtchild=0;
  locale=loc;
  menubar=0;
  tab=0;
  closed=false;
  shown=false;
  setAttribute(Qt::WA_DeleteOnClose);
  QStringList m=s2q(p).split(' ',QString::SkipEmptyParts);
  escclose=m.contains("escclose");
  closeok=escclose||m.contains("closeok");
  setpn(s);

  Qt::WindowFlags flags=0;
  if (m.contains("dialog")) flags=Qt::Dialog|Qt::WindowTitleHint|Qt::WindowStaysOnTopHint|Qt::CustomizeWindowHint;
  if (m.contains("popup")) flags=Qt::Popup;
  if (m.contains("minbutton")) flags|=Qt::WindowMinimizeButtonHint;
  if (m.contains("maxbutton")) flags|=Qt::WindowMaximizeButtonHint;
  if (m.contains("closebutton")) flags|=Qt::WindowCloseButtonHint;
  if (m.contains("ptop")) flags=Qt::WindowStaysOnTopHint;
#if defined(ANDROID) && defined(QT_OPENGL)
  flags|=Qt::Window;
  setWindowModality(Qt::WindowModal);
#else
  if (m.contains("owner")) {
    flags|=Qt::Window;
    setWindowModality(Qt::WindowModal);
  }
#endif
  setWindowFlags(flags);

  layout=new QVBoxLayout(this);
  setpadding(0,0,0,0);
  layout->setSpacing(0);
  if (m.contains("nosize")) layout->setSizeConstraint( QLayout::SetFixedSize );
  addpane(0);
  signalMapper=new QSignalMapper(this);
  connect(signalMapper,SIGNAL(mapped(QWidget *)),
          this,SLOT(buttonClicked(QWidget *)));
}

// ---------------------------------------------------------------------
Form::~Form()
{
  Child *n;
  for (int i=0; i<children.size(); i++)
    if ("isigraph"==(n=children.at(i))->type) {
      if (((Isigraph2*)n->widget)->painter) {
        ((Isigraph2*)n->widget)->painter->end();
        delete ((Isigraph2*)n->widget)->painter;
        ((Isigraph2*)n->widget)->painter=0;
      }
#ifdef QT_OPENGL
    } else if ("opengl"==(n=children.at(i))->type) {
      if (((Opengl2*)n->widget)->painter) {
        ((Opengl2*)n->widget)->painter->end();
        delete ((Opengl2*)n->widget)->painter;
        ((Opengl2*)n->widget)->painter=0;
      }
#endif
    }
  if (this==form) form = 0;
  if (this==evtform) evtform = 0;
  Forms.removeOne(this);
#if defined(ANDROID) && defined(QT_OPENGL)
  if (!Forms.size()) showide(true);
#endif
  if (Forms.isEmpty() && (!ShowIde))
    term->filequit();
}

// ---------------------------------------------------------------------
void Form::addchild(Child *c)
{
  child=c;
  children.append(c);
}

// ---------------------------------------------------------------------
void Form::addmenu()
{
  menubar= new Menus("menu","",this,0);
  addchild((Child *) menubar);
  layout->insertWidget(0,child->widget);
}

// ---------------------------------------------------------------------
Pane *Form::addpane(int n)
{
  pane=new Pane(n,this);
  panes.append(pane);
  return pane;
}

// ---------------------------------------------------------------------
void Form::buttonClicked(QWidget *w)
{
  Child *child=(Child *) w;
  child->event="button";
  signalevent(child);
}

// ---------------------------------------------------------------------
void Form::closeEvent(QCloseEvent *e)
{
  if (closeok || closed) {
    e->accept();
    return;
  }
  e->ignore();
  event="close";
  fakeid="";
  form=this;
  signalevent(0);
  if (closed) {
    e->accept();
  } else e->ignore();
}

// ---------------------------------------------------------------------
// close if not the main pane
void Form::closepane()
{
  if (panes.size()<=1) return;
  panes.removeLast();
  pane=panes.last();
}

// ---------------------------------------------------------------------
string Form::hschild()
{
  return p2s((void *)child);
}

// ---------------------------------------------------------------------
string Form::hsform()
{
  return p2s((void *)this);
}

// ---------------------------------------------------------------------
string Form::qform()
{
  return i2s(pos().x())+" "+i2s(pos().y())+" "+i2s(size().width())+" "+i2s(size().height());
}

// ---------------------------------------------------------------------
Child *Form::id2child(string n)
{
  for (int i=0; i<children.size(); i++)
    if ("menu"!=children.at(i)->type && n==children.at(i)->id)
      return children.at(i);
  return (Child *) 0;
}

// ---------------------------------------------------------------------
bool Form::ischild(Child *n)
{
  return children.contains(n);
}

// ---------------------------------------------------------------------
void Form::keyPressEvent(QKeyEvent *e)
{
  int k=e->key();
#ifdef ANDROID
  if (k==Qt::Key_MediaPrevious) {
    activateWindow();
    raise();
    close();
    return;
  }
#endif
  if (escclose && k==Qt::Key_Escape) {
    e->ignore();
    delete this;
  } else if (k>=Qt::Key_F1 && k<=Qt::Key_F35) {
    event="fkey";
    form=this;
    signalevent(0,e);
  } else if (k>=Qt::Key_A && k<=Qt::Key_Z && (e->modifiers() & Qt::ControlModifier)) {
    event="fkey";
    form=this;
    signalevent(0,e);
  }
}

// ---------------------------------------------------------------------
Child *Form::setmenuid(string id)
{
  if (menubar && menubar->items.contains(s2q(id)))
    return (Child *) menubar;
  return (Child *) 0;
}

// ---------------------------------------------------------------------
void Form::setpadding(int l,int t,int r,int b)
{
  layout->setContentsMargins(l,t,r,b);
}

// ---------------------------------------------------------------------
void Form::setpn(string p)
{
  setWindowTitle(s2q(p));
}

// ---------------------------------------------------------------------
void Form::setpicon(string p)
{
  QString s=s2q(p);
  setWindowIcon(QIcon(s));
}

// ---------------------------------------------------------------------
void Form::showit()
{
  for (int i=tabs.size()-1; i>=0; i--)
    tabs.last()->tabend();
  for (int i=panes.size()-1; i>=0; i--)
    panes.last()->fini();
  layout->addWidget(pane);
  setLayout(layout);
  show();
#ifdef ANDROID
  activateWindow();
  raise();
#endif

  shown=true;
}

// ---------------------------------------------------------------------
void Form::signalevent(Child *c, QKeyEvent *e)
{
  if (NoEvents || closed) return;
  string loc = locale;
  evtform=this;
  if (c) {
    evtchild=c;
    c->setform();
    sysmodifiers=c->sysmodifiers;
    sysdata=c->sysdata;
    loc = (""!=c->locale)?c->locale:locale;
  } else {
    evtchild=0;
    if (event=="fkey") {
      int k=e->key();
      if (k>=Qt::Key_A && k<=Qt::Key_Z && (e->modifiers() & Qt::ControlModifier)) {
        fakeid=(char)e->key()+32;  // lower case
        fakeid=fakeid + "ctrl" + string( (e->modifiers() & Qt::ShiftModifier) ? "shift" : "" );
      } else if (k>=Qt::Key_F1 && k<=Qt::Key_F35) {
        ostringstream ostr;
        ostr << e->key()+1-Qt::Key_F1;
        fakeid="f"+ ostr.str() + string((e->modifiers() & Qt::ControlModifier) ? "ctrl" : "") + string((e->modifiers() & Qt::ShiftModifier) ? "shift" : "");
      }
    }
  }
  var_cmddo("(i.0 0)\"_ wdhandler_" + s2q(loc) + "_$0");
}

// ---------------------------------------------------------------------
string Form::state(int evt)
{
  string c,c1,e,r,s,ec;

  if (evt) {
    if (evtchild) {
      c=evtchild->eid;
      e=evtchild->event;
      ec=evtchild->locale;
    } else {
      c=fakeid;
      e=event;
    }
    c1=(c.empty()) ? string("") : (c+"_") ;
    r+=spair("syshandler",id+"_handler");
    r+=spair("sysevent",id+"_"+c1+e);
    r+=spair("sysdefault",id+"_default");
    r+=spair("sysparent",id);
    r+=spair("syschild",c);
    r+=spair("systype",e);
    r+=spair("syslocalec",ec);
  }

  // need only syslocale (not syslocalep, syslocalec)?...  in isigraph
  r+=spair("syslocalep",locale);
  r+=spair("syshwndp",hsform());
  r+=spair("syshwndc",hschild());
  r+=spair("syslastfocus","");
  r+=spair("sysmodifiers",sysmodifiers);
  r+=spair("sysdata",sysdata);

  for (int i=0; i<children.size(); i++)
    s+=children.at(i)->state();

  return r+s;
}

// ---------------------------------------------------------------------
// for debugging
void Form::status(string s)
{
  qDebug() << "form status: " << s2q(s);
  qDebug() << "current pane, panes: " << pane << panes;
  qDebug() << "current tab, tabs: " << tab << tabs;
}
<commit_msg>escclose no longer sets closeok<commit_after>
#include <QBoxLayout>
#include <QMenuBar>
#include <QSignalMapper>

#include <sstream>  //include this to use string streams

#include "wd.h"
#include "font.h"
#include "cmd.h"
#include "form.h"
#include "pane.h"
#include "tabs.h"
#include "child.h"
#include "isigraph2.h"
#include "menus.h"
#ifdef QT_OPENGL
#include "opengl2.h"
#endif
#include "../base/state.h"
#include "../base/term.h"

// ---------------------------------------------------------------------
Form::Form(string s, string p, string loc, QWidget *parent) : QWidget (parent)
{
  Q_UNUSED(parent);
  id=s;
  child=0;
  evtchild=0;
  locale=loc;
  menubar=0;
  tab=0;
  closed=false;
  shown=false;
  setAttribute(Qt::WA_DeleteOnClose);
  QStringList m=s2q(p).split(' ',QString::SkipEmptyParts);
  escclose=m.contains("escclose");
  closeok=m.contains("closeok");
  setpn(s);

  Qt::WindowFlags flags=0;
  if (m.contains("dialog")) flags=Qt::Dialog|Qt::WindowTitleHint|Qt::WindowStaysOnTopHint|Qt::CustomizeWindowHint;
  if (m.contains("popup")) flags=Qt::Popup;
  if (m.contains("minbutton")) flags|=Qt::WindowMinimizeButtonHint;
  if (m.contains("maxbutton")) flags|=Qt::WindowMaximizeButtonHint;
  if (m.contains("closebutton")) flags|=Qt::WindowCloseButtonHint;
  if (m.contains("ptop")) flags=Qt::WindowStaysOnTopHint;
#if defined(ANDROID) && defined(QT_OPENGL)
  flags|=Qt::Window;
  setWindowModality(Qt::WindowModal);
#else
  if (m.contains("owner")) {
    flags|=Qt::Window;
    setWindowModality(Qt::WindowModal);
  }
#endif
  setWindowFlags(flags);

  layout=new QVBoxLayout(this);
  setpadding(0,0,0,0);
  layout->setSpacing(0);
  if (m.contains("nosize")) layout->setSizeConstraint( QLayout::SetFixedSize );
  addpane(0);
  signalMapper=new QSignalMapper(this);
  connect(signalMapper,SIGNAL(mapped(QWidget *)),
          this,SLOT(buttonClicked(QWidget *)));
}

// ---------------------------------------------------------------------
Form::~Form()
{
  Child *n;
  for (int i=0; i<children.size(); i++)
    if ("isigraph"==(n=children.at(i))->type) {
      if (((Isigraph2*)n->widget)->painter) {
        ((Isigraph2*)n->widget)->painter->end();
        delete ((Isigraph2*)n->widget)->painter;
        ((Isigraph2*)n->widget)->painter=0;
      }
#ifdef QT_OPENGL
    } else if ("opengl"==(n=children.at(i))->type) {
      if (((Opengl2*)n->widget)->painter) {
        ((Opengl2*)n->widget)->painter->end();
        delete ((Opengl2*)n->widget)->painter;
        ((Opengl2*)n->widget)->painter=0;
      }
#endif
    }
  if (this==form) form = 0;
  if (this==evtform) evtform = 0;
  Forms.removeOne(this);
#if defined(ANDROID) && defined(QT_OPENGL)
  if (!Forms.size()) showide(true);
#endif
  if (Forms.isEmpty() && (!ShowIde))
    term->filequit();
}

// ---------------------------------------------------------------------
void Form::addchild(Child *c)
{
  child=c;
  children.append(c);
}

// ---------------------------------------------------------------------
void Form::addmenu()
{
  menubar= new Menus("menu","",this,0);
  addchild((Child *) menubar);
  layout->insertWidget(0,child->widget);
}

// ---------------------------------------------------------------------
Pane *Form::addpane(int n)
{
  pane=new Pane(n,this);
  panes.append(pane);
  return pane;
}

// ---------------------------------------------------------------------
void Form::buttonClicked(QWidget *w)
{
  Child *child=(Child *) w;
  child->event="button";
  signalevent(child);
}

// ---------------------------------------------------------------------
void Form::closeEvent(QCloseEvent *e)
{
  if (closeok || closed) {
    e->accept();
    return;
  }
  e->ignore();
  event="close";
  fakeid="";
  form=this;
  signalevent(0);
  if (closed) {
    e->accept();
  } else e->ignore();
}

// ---------------------------------------------------------------------
// close if not the main pane
void Form::closepane()
{
  if (panes.size()<=1) return;
  panes.removeLast();
  pane=panes.last();
}

// ---------------------------------------------------------------------
string Form::hschild()
{
  return p2s((void *)child);
}

// ---------------------------------------------------------------------
string Form::hsform()
{
  return p2s((void *)this);
}

// ---------------------------------------------------------------------
string Form::qform()
{
  return i2s(pos().x())+" "+i2s(pos().y())+" "+i2s(size().width())+" "+i2s(size().height());
}

// ---------------------------------------------------------------------
Child *Form::id2child(string n)
{
  for (int i=0; i<children.size(); i++)
    if ("menu"!=children.at(i)->type && n==children.at(i)->id)
      return children.at(i);
  return (Child *) 0;
}

// ---------------------------------------------------------------------
bool Form::ischild(Child *n)
{
  return children.contains(n);
}

// ---------------------------------------------------------------------
void Form::keyPressEvent(QKeyEvent *e)
{
  int k=e->key();
#ifdef ANDROID
  if (k==Qt::Key_MediaPrevious) {
    activateWindow();
    raise();
    close();
    return;
  }
#endif
  if (escclose && k==Qt::Key_Escape) {
    e->ignore();
    if (closeok)
      delete this;
    else  {
      event="close";
      fakeid="";
      form=this;
      signalevent(0);
    }
  } else if (k>=Qt::Key_F1 && k<=Qt::Key_F35) {
    event="fkey";
    form=this;
    signalevent(0,e);
  } else if (k>=Qt::Key_A && k<=Qt::Key_Z && (e->modifiers() & Qt::ControlModifier)) {
    event="fkey";
    form=this;
    signalevent(0,e);
  }
}

// ---------------------------------------------------------------------
Child *Form::setmenuid(string id)
{
  if (menubar && menubar->items.contains(s2q(id)))
    return (Child *) menubar;
  return (Child *) 0;
}

// ---------------------------------------------------------------------
void Form::setpadding(int l,int t,int r,int b)
{
  layout->setContentsMargins(l,t,r,b);
}

// ---------------------------------------------------------------------
void Form::setpn(string p)
{
  setWindowTitle(s2q(p));
}

// ---------------------------------------------------------------------
void Form::setpicon(string p)
{
  QString s=s2q(p);
  setWindowIcon(QIcon(s));
}

// ---------------------------------------------------------------------
void Form::showit()
{
  for (int i=tabs.size()-1; i>=0; i--)
    tabs.last()->tabend();
  for (int i=panes.size()-1; i>=0; i--)
    panes.last()->fini();
  layout->addWidget(pane);
  setLayout(layout);
  show();
#ifdef ANDROID
  activateWindow();
  raise();
#endif

  shown=true;
}

// ---------------------------------------------------------------------
void Form::signalevent(Child *c, QKeyEvent *e)
{
  if (NoEvents || closed) return;
  string loc = locale;
  evtform=this;
  if (c) {
    evtchild=c;
    c->setform();
    sysmodifiers=c->sysmodifiers;
    sysdata=c->sysdata;
    loc = (""!=c->locale)?c->locale:locale;
  } else {
    evtchild=0;
    if (event=="fkey") {
      int k=e->key();
      if (k>=Qt::Key_A && k<=Qt::Key_Z && (e->modifiers() & Qt::ControlModifier)) {
        fakeid=(char)e->key()+32;  // lower case
        fakeid=fakeid + "ctrl" + string( (e->modifiers() & Qt::ShiftModifier) ? "shift" : "" );
      } else if (k>=Qt::Key_F1 && k<=Qt::Key_F35) {
        ostringstream ostr;
        ostr << e->key()+1-Qt::Key_F1;
        fakeid="f"+ ostr.str() + string((e->modifiers() & Qt::ControlModifier) ? "ctrl" : "") + string((e->modifiers() & Qt::ShiftModifier) ? "shift" : "");
      }
    }
  }
  var_cmddo("(i.0 0)\"_ wdhandler_" + s2q(loc) + "_$0");
}

// ---------------------------------------------------------------------
string Form::state(int evt)
{
  string c,c1,e,r,s,ec;

  if (evt) {
    if (evtchild) {
      c=evtchild->eid;
      e=evtchild->event;
      ec=evtchild->locale;
    } else {
      c=fakeid;
      e=event;
    }
    c1=(c.empty()) ? string("") : (c+"_") ;
    r+=spair("syshandler",id+"_handler");
    r+=spair("sysevent",id+"_"+c1+e);
    r+=spair("sysdefault",id+"_default");
    r+=spair("sysparent",id);
    r+=spair("syschild",c);
    r+=spair("systype",e);
    r+=spair("syslocalec",ec);
  }

  // need only syslocale (not syslocalep, syslocalec)?...  in isigraph
  r+=spair("syslocalep",locale);
  r+=spair("syshwndp",hsform());
  r+=spair("syshwndc",hschild());
  r+=spair("syslastfocus","");
  r+=spair("sysmodifiers",sysmodifiers);
  r+=spair("sysdata",sysdata);

  for (int i=0; i<children.size(); i++)
    s+=children.at(i)->state();

  return r+s;
}

// ---------------------------------------------------------------------
// for debugging
void Form::status(string s)
{
  qDebug() << "form status: " << s2q(s);
  qDebug() << "current pane, panes: " << pane << panes;
  qDebug() << "current tab, tabs: " << tab << tabs;
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: DAVException.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-20 05:33:18 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _DAVEXCEPTION_HXX_
#define _DAVEXCEPTION_HXX_

#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif

namespace webdav_ucp
{

/////////////////////////////////////////////////////////////////////////////
// HTTP/WebDAV status codes
/////////////////////////////////////////////////////////////////////////////

const sal_uInt16 SC_NONE                             = 0;

// 1xx (Informational - no errors)
const sal_uInt16 SC_CONTINUE                         = 100;
const sal_uInt16 SC_SWITCHING_PROTOCOLS              = 101;
// DAV extensions
const sal_uInt16 SC_PROCESSING                       = 102;

//2xx (Successful - no errors)
const sal_uInt16 SC_OK                               = 200;
const sal_uInt16 SC_CREATED                          = 201;
const sal_uInt16 SC_ACCEPTED                         = 202;
const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION    = 203;
const sal_uInt16 SC_NO_CONTENT                       = 204;
const sal_uInt16 SC_RESET_CONTENT                    = 205;
const sal_uInt16 SC_PARTIAL_CONTENT                  = 206;
// DAV extensions
const sal_uInt16 SC_MULTISTATUS                      = 207;

//3xx (Redirection)
const sal_uInt16 SC_MULTIPLE_CHOICES                 = 300;
const sal_uInt16 SC_MOVED_PERMANENTLY                = 301;
const sal_uInt16 SC_MOVED_TEMPORARILY                = 302;
const sal_uInt16 SC_SEE_OTHER                        = 303;
const sal_uInt16 SC_NOT_MODIFIED                     = 304;
const sal_uInt16 SC_USE_PROXY                        = 305;
const sal_uInt16 SC_TEMPORARY_REDIRECT               = 307;

//4xx (Client error)
const sal_uInt16 SC_BAD_REQUEST                      = 400;
const sal_uInt16 SC_UNAUTHORIZED                     = 401;
const sal_uInt16 SC_PAYMENT_REQUIRED                 = 402;
const sal_uInt16 SC_FORBIDDEN                        = 403;
const sal_uInt16 SC_NOT_FOUND                        = 404;
const sal_uInt16 SC_METHOD_NOT_ALLOWED               = 405;
const sal_uInt16 SC_NOT_ACCEPTABLE                   = 406;
const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED    = 407;
const sal_uInt16 SC_REQUEST_TIMEOUT                  = 408;
const sal_uInt16 SC_CONFLICT                         = 409;
const sal_uInt16 SC_GONE                             = 410;
const sal_uInt16 SC_LENGTH_REQUIRED                  = 411;
const sal_uInt16 SC_PRECONDITION_FAILED              = 412;
const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE         = 413;
const sal_uInt16 SC_REQUEST_URI_TOO_LONG             = 414;
const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE           = 415;
const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE  = 416;
const sal_uInt16 SC_EXPECTATION_FAILED               = 417;
// DAV extensions
const sal_uInt16 SC_UNPROCESSABLE_ENTITY             = 422;
const sal_uInt16 SC_LOCKED                           = 423;
const sal_uInt16 SC_FAILED_DEPENDENCY                = 424;

//5xx (Server error)
const sal_uInt16 SC_INTERNAL_SERVER_ERROR            = 500;
const sal_uInt16 SC_NOT_IMPLEMENTED                  = 501;
const sal_uInt16 SC_BAD_GATEWAY                      = 502;
const sal_uInt16 SC_SERVICE_UNAVAILABLE              = 503;
const sal_uInt16 SC_GATEWAY_TIMEOUT                  = 504;
const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED       = 505;
// DAV extensions
const sal_uInt16 SC_INSUFFICIENT_STORAGE             = 507;

/////////////////////////////////////////////////////////////////////////////

class DAVException
{
    public:
        enum ExceptionCode {
            DAV_HTTP_ERROR = 0, // Generic error, mData = error message
            DAV_HTTP_LOOKUP,    // Name lookup failed, mData = server[:port]
            DAV_HTTP_AUTH,      // User authentication failed on server
            DAV_HTTP_AUTHPROXY, // User authentication failed on proxy
            DAV_HTTP_CONNECT,   // Could not connect to server, mData = server[:port]
            DAV_HTTP_TIMEOUT,   // Connection timed out
            DAV_HTTP_FAILED,    // The precondition failed
            DAV_HTTP_RETRY,     // Retry request
            DAV_HTTP_REDIRECT,  // See http_redirect.h, mData = new URL
            DAV_SESSION_CREATE, // session creation error, mData = server[:port]
            DAV_INVALID_ARG };  // mData = file URL

    private:
        ExceptionCode   mExceptionCode;
        rtl::OUString   mData;
        sal_uInt16      mStatusCode;

    public:
         DAVException( ExceptionCode inExceptionCode ) :
            mExceptionCode( inExceptionCode ), mStatusCode( SC_NONE ) {};
         DAVException( ExceptionCode inExceptionCode,
                       const rtl::OUString & rData ) :
            mExceptionCode( inExceptionCode ), mData( rData ),
            mStatusCode( SC_NONE ) {};
         DAVException( ExceptionCode inExceptionCode,
                       const rtl::OUString & rData,
                       sal_uInt16 nStatusCode ) :
            mExceptionCode( inExceptionCode ), mData( rData ),
            mStatusCode( nStatusCode ) {};
        ~DAVException( ) {};

    const ExceptionCode & getError() const { return mExceptionCode; }
    const rtl::OUString & getData() const  { return mData; }
    sal_uInt16 getStatus() const { return mStatusCode; }
};

} // namespace webdav_ucp

#endif // _DAVEXCEPTION_HXX_
<commit_msg>INTEGRATION: CWS changefileheader (1.8.138); FILE MERGED 2008/04/01 16:02:24 thb 1.8.138.2: #i85898# Stripping all external header guards 2008/03/31 15:30:29 rt 1.8.138.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: DAVException.hxx,v $
 * $Revision: 1.9 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _DAVEXCEPTION_HXX_
#define _DAVEXCEPTION_HXX_

#include <rtl/ustring.hxx>

namespace webdav_ucp
{

/////////////////////////////////////////////////////////////////////////////
// HTTP/WebDAV status codes
/////////////////////////////////////////////////////////////////////////////

const sal_uInt16 SC_NONE                             = 0;

// 1xx (Informational - no errors)
const sal_uInt16 SC_CONTINUE                         = 100;
const sal_uInt16 SC_SWITCHING_PROTOCOLS              = 101;
// DAV extensions
const sal_uInt16 SC_PROCESSING                       = 102;

//2xx (Successful - no errors)
const sal_uInt16 SC_OK                               = 200;
const sal_uInt16 SC_CREATED                          = 201;
const sal_uInt16 SC_ACCEPTED                         = 202;
const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION    = 203;
const sal_uInt16 SC_NO_CONTENT                       = 204;
const sal_uInt16 SC_RESET_CONTENT                    = 205;
const sal_uInt16 SC_PARTIAL_CONTENT                  = 206;
// DAV extensions
const sal_uInt16 SC_MULTISTATUS                      = 207;

//3xx (Redirection)
const sal_uInt16 SC_MULTIPLE_CHOICES                 = 300;
const sal_uInt16 SC_MOVED_PERMANENTLY                = 301;
const sal_uInt16 SC_MOVED_TEMPORARILY                = 302;
const sal_uInt16 SC_SEE_OTHER                        = 303;
const sal_uInt16 SC_NOT_MODIFIED                     = 304;
const sal_uInt16 SC_USE_PROXY                        = 305;
const sal_uInt16 SC_TEMPORARY_REDIRECT               = 307;

//4xx (Client error)
const sal_uInt16 SC_BAD_REQUEST                      = 400;
const sal_uInt16 SC_UNAUTHORIZED                     = 401;
const sal_uInt16 SC_PAYMENT_REQUIRED                 = 402;
const sal_uInt16 SC_FORBIDDEN                        = 403;
const sal_uInt16 SC_NOT_FOUND                        = 404;
const sal_uInt16 SC_METHOD_NOT_ALLOWED               = 405;
const sal_uInt16 SC_NOT_ACCEPTABLE                   = 406;
const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED    = 407;
const sal_uInt16 SC_REQUEST_TIMEOUT                  = 408;
const sal_uInt16 SC_CONFLICT                         = 409;
const sal_uInt16 SC_GONE                             = 410;
const sal_uInt16 SC_LENGTH_REQUIRED                  = 411;
const sal_uInt16 SC_PRECONDITION_FAILED              = 412;
const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE         = 413;
const sal_uInt16 SC_REQUEST_URI_TOO_LONG             = 414;
const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE           = 415;
const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE  = 416;
const sal_uInt16 SC_EXPECTATION_FAILED               = 417;
// DAV extensions
const sal_uInt16 SC_UNPROCESSABLE_ENTITY             = 422;
const sal_uInt16 SC_LOCKED                           = 423;
const sal_uInt16 SC_FAILED_DEPENDENCY                = 424;

//5xx (Server error)
const sal_uInt16 SC_INTERNAL_SERVER_ERROR            = 500;
const sal_uInt16 SC_NOT_IMPLEMENTED                  = 501;
const sal_uInt16 SC_BAD_GATEWAY                      = 502;
const sal_uInt16 SC_SERVICE_UNAVAILABLE              = 503;
const sal_uInt16 SC_GATEWAY_TIMEOUT                  = 504;
const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED       = 505;
// DAV extensions
const sal_uInt16 SC_INSUFFICIENT_STORAGE             = 507;

/////////////////////////////////////////////////////////////////////////////

class DAVException
{
    public:
        enum ExceptionCode {
            DAV_HTTP_ERROR = 0, // Generic error, mData = error message
            DAV_HTTP_LOOKUP,    // Name lookup failed, mData = server[:port]
            DAV_HTTP_AUTH,      // User authentication failed on server
            DAV_HTTP_AUTHPROXY, // User authentication failed on proxy
            DAV_HTTP_CONNECT,   // Could not connect to server, mData = server[:port]
            DAV_HTTP_TIMEOUT,   // Connection timed out
            DAV_HTTP_FAILED,    // The precondition failed
            DAV_HTTP_RETRY,     // Retry request
            DAV_HTTP_REDIRECT,  // See http_redirect.h, mData = new URL
            DAV_SESSION_CREATE, // session creation error, mData = server[:port]
            DAV_INVALID_ARG };  // mData = file URL

    private:
        ExceptionCode   mExceptionCode;
        rtl::OUString   mData;
        sal_uInt16      mStatusCode;

    public:
         DAVException( ExceptionCode inExceptionCode ) :
            mExceptionCode( inExceptionCode ), mStatusCode( SC_NONE ) {};
         DAVException( ExceptionCode inExceptionCode,
                       const rtl::OUString & rData ) :
            mExceptionCode( inExceptionCode ), mData( rData ),
            mStatusCode( SC_NONE ) {};
         DAVException( ExceptionCode inExceptionCode,
                       const rtl::OUString & rData,
                       sal_uInt16 nStatusCode ) :
            mExceptionCode( inExceptionCode ), mData( rData ),
            mStatusCode( nStatusCode ) {};
        ~DAVException( ) {};

    const ExceptionCode & getError() const { return mExceptionCode; }
    const rtl::OUString & getData() const  { return mData; }
    sal_uInt16 getStatus() const { return mStatusCode; }
};

} // namespace webdav_ucp

#endif // _DAVEXCEPTION_HXX_
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: filrow.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 15:27:00 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _FILROW_HXX_
#include "filrow.hxx"
#endif
#ifndef _SHELL_HXX_
#include "shell.hxx"
#endif
#ifndef _PROV_HXX_
#include "prov.hxx"
#endif

using namespace fileaccess;
using namespace com::sun::star;
using namespace com::sun::star::uno;
//using namespace com::sun::star::ucb;

// Funktion for TypeConverting

template< class _type_ >
sal_Bool convert( shell* pShell,
                  uno::Reference< script::XTypeConverter >& xConverter,
                  uno::Any& rValue,
                  _type_& aReturn  )
{
    // Try first without converting
    sal_Bool no_success = ! ( rValue >>= aReturn );

    if ( no_success )
    {
        if( ! xConverter.is() )
        {
            xConverter = uno::Reference< script::XTypeConverter >(
                pShell->m_xMultiServiceFactory->createInstance(
                    rtl::OUString::createFromAscii( "com.sun.star.script.Converter" ) ),uno::UNO_QUERY );

/*          DBG_ASSERT( m_xTypeConverter.is(),
                        "PropertyValueSet::getTypeConverter() - "
                        "Service 'com.sun.star.script.Converter' n/a!" );*/
        }

        try
        {
            if( rValue.hasValue() )
            {
                uno::Any aConvertedValue
                    = xConverter->convertTo( rValue,getCppuType( static_cast< const _type_* >(0) ) );
                no_success = ! ( aConvertedValue >>= aReturn );
            }
            else
                no_success = sal_True;
        }
        catch ( lang::IllegalArgumentException )
        {
            no_success = sal_True;
        }
        catch ( script::CannotConvertException )
        {
            no_success = sal_True;
        }
    }
    return no_success;
}

XRow_impl::XRow_impl( shell* pMyShell,const uno::Sequence< uno::Any >& seq )
    : m_aValueMap( seq ),
      m_pMyShell( pMyShell ),
      m_xProvider( pMyShell->m_pProvider ),
      m_xTypeConverter( 0 )
{
}

XRow_impl::~XRow_impl()
{
}

void SAL_CALL
XRow_impl::acquire(
           void )
  throw()
{
  OWeakObject::acquire();
}

void SAL_CALL
XRow_impl::release(
           void )
  throw()
{
  OWeakObject::release();
}

uno::Any SAL_CALL
XRow_impl::queryInterface(
              const uno::Type& rType )
  throw( uno::RuntimeException )
{
  uno::Any aRet = cppu::queryInterface( rType,
                    SAL_STATIC_CAST( lang::XTypeProvider*,this),
                    SAL_STATIC_CAST( sdbc::XRow*,this) );
  return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
}

XTYPEPROVIDER_IMPL_2( XRow_impl,
                         lang::XTypeProvider,
                      sdbc::XRow )

sal_Bool SAL_CALL
XRow_impl::wasNull(
           void )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  return m_nWasNull;
}

rtl::OUString SAL_CALL
XRow_impl::getString(
             sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
    throw sdbc::SQLException();
  rtl::OUString  Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert<rtl::OUString>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

sal_Bool SAL_CALL
XRow_impl::getBoolean(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Bool  Value( false );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Bool>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int8 SAL_CALL
XRow_impl::getByte(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int8  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int8>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int16 SAL_CALL
XRow_impl::getShort(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int16  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int16>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int32 SAL_CALL
XRow_impl::getInt(
          sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int32  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int32>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int64 SAL_CALL
XRow_impl::getLong(
           sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int64  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int64>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

float SAL_CALL
XRow_impl::getFloat(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    float  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<float>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

double SAL_CALL
XRow_impl::getDouble(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    double  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<double>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

uno::Sequence< sal_Int8 > SAL_CALL
XRow_impl::getBytes(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Sequence< sal_Int8 >  Value(0);
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Sequence< sal_Int8 > >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

util::Date SAL_CALL
XRow_impl::getDate(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    util::Date  Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<util::Date>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

util::Time SAL_CALL
XRow_impl::getTime(
    sal_Int32 columnIndex )
  throw( sdbc::SQLException,
         uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    util::Time  Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<util::Time>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

util::DateTime SAL_CALL
XRow_impl::getTimestamp(
            sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
    throw sdbc::SQLException();
  util::DateTime  Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert<util::DateTime>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

uno::Reference< io::XInputStream > SAL_CALL
XRow_impl::getBinaryStream(
               sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
    throw sdbc::SQLException();
  uno::Reference< io::XInputStream >  Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert<uno::Reference< io::XInputStream > >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

uno::Reference< io::XInputStream > SAL_CALL
XRow_impl::getCharacterStream(
                  sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
      throw sdbc::SQLException();
  uno::Reference< io::XInputStream > Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert< uno::Reference< io::XInputStream> >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

uno::Any SAL_CALL
XRow_impl::getObject(
    sal_Int32 columnIndex,
    const uno::Reference< container::XNameAccess >& typeMap )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Any  Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Any>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

uno::Reference< sdbc::XRef > SAL_CALL
XRow_impl::getRef(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XRef > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XRef> >( m_pMyShell,
                                                          m_xTypeConverter,
                                                          m_aValueMap[ --columnIndex ],
                                                          Value );
    return Value;
}

uno::Reference< sdbc::XBlob > SAL_CALL
XRow_impl::getBlob(
           sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XBlob > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XBlob> >( m_pMyShell,
                                                           m_xTypeConverter,
                                                           m_aValueMap[ --columnIndex ],
                                                           Value );
    return Value;
}

uno::Reference< sdbc::XClob > SAL_CALL
XRow_impl::getClob(
           sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XClob > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XClob> >( m_pMyShell,
                                                           m_xTypeConverter,
                                                           m_aValueMap[ --columnIndex ],
                                                           Value );
    return Value;
}

uno::Reference< sdbc::XArray > SAL_CALL
XRow_impl::getArray(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XArray > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XArray> >( m_pMyShell,
                                                            m_xTypeConverter,
                                                            m_aValueMap[ --columnIndex ],
                                                            Value );
    return Value;
}
<commit_msg>INTEGRATION: CWS warnings01 (1.6.10); FILE MERGED 2005/11/09 21:01:53 sb 1.6.10.1: #i53898# Made code warning-free.<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: filrow.cxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-20 05:20:48 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _FILROW_HXX_
#include "filrow.hxx"
#endif
#ifndef _SHELL_HXX_
#include "shell.hxx"
#endif
#ifndef _PROV_HXX_
#include "prov.hxx"
#endif

using namespace fileaccess;
using namespace com::sun::star;
using namespace com::sun::star::uno;
//using namespace com::sun::star::ucb;

// Funktion for TypeConverting

template< class _type_ >
sal_Bool convert( shell* pShell,
                  uno::Reference< script::XTypeConverter >& xConverter,
                  uno::Any& rValue,
                  _type_& aReturn  )
{
    // Try first without converting
    sal_Bool no_success = ! ( rValue >>= aReturn );

    if ( no_success )
    {
        if( ! xConverter.is() )
        {
            xConverter = uno::Reference< script::XTypeConverter >(
                pShell->m_xMultiServiceFactory->createInstance(
                    rtl::OUString::createFromAscii( "com.sun.star.script.Converter" ) ),uno::UNO_QUERY );

/*          DBG_ASSERT( m_xTypeConverter.is(),
                        "PropertyValueSet::getTypeConverter() - "
                        "Service 'com.sun.star.script.Converter' n/a!" );*/
        }

        try
        {
            if( rValue.hasValue() )
            {
                uno::Any aConvertedValue
                    = xConverter->convertTo( rValue,getCppuType( static_cast< const _type_* >(0) ) );
                no_success = ! ( aConvertedValue >>= aReturn );
            }
            else
                no_success = sal_True;
        }
        catch ( lang::IllegalArgumentException )
        {
            no_success = sal_True;
        }
        catch ( script::CannotConvertException )
        {
            no_success = sal_True;
        }
    }
    return no_success;
}

XRow_impl::XRow_impl( shell* pMyShell,const uno::Sequence< uno::Any >& seq )
    : m_aValueMap( seq ),
      m_pMyShell( pMyShell ),
      m_xProvider( pMyShell->m_pProvider ),
      m_xTypeConverter( 0 )
{
}

XRow_impl::~XRow_impl()
{
}

void SAL_CALL
XRow_impl::acquire(
           void )
  throw()
{
  OWeakObject::acquire();
}

void SAL_CALL
XRow_impl::release(
           void )
  throw()
{
  OWeakObject::release();
}

uno::Any SAL_CALL
XRow_impl::queryInterface(
              const uno::Type& rType )
  throw( uno::RuntimeException )
{
  uno::Any aRet = cppu::queryInterface( rType,
                    SAL_STATIC_CAST( lang::XTypeProvider*,this),
                    SAL_STATIC_CAST( sdbc::XRow*,this) );
  return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
}

XTYPEPROVIDER_IMPL_2( XRow_impl,
                         lang::XTypeProvider,
                      sdbc::XRow )

sal_Bool SAL_CALL
XRow_impl::wasNull(
           void )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  return m_nWasNull;
}

rtl::OUString SAL_CALL
XRow_impl::getString(
             sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
    throw sdbc::SQLException();
  rtl::OUString  Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert<rtl::OUString>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

sal_Bool SAL_CALL
XRow_impl::getBoolean(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Bool  Value( false );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Bool>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int8 SAL_CALL
XRow_impl::getByte(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int8  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int8>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int16 SAL_CALL
XRow_impl::getShort(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int16  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int16>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int32 SAL_CALL
XRow_impl::getInt(
          sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int32  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int32>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

sal_Int64 SAL_CALL
XRow_impl::getLong(
           sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    sal_Int64  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<sal_Int64>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

float SAL_CALL
XRow_impl::getFloat(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    float  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<float>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

double SAL_CALL
XRow_impl::getDouble(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    double  Value( 0 );
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<double>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

uno::Sequence< sal_Int8 > SAL_CALL
XRow_impl::getBytes(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Sequence< sal_Int8 >  Value(0);
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Sequence< sal_Int8 > >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

util::Date SAL_CALL
XRow_impl::getDate(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    util::Date  Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<util::Date>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

util::Time SAL_CALL
XRow_impl::getTime(
    sal_Int32 columnIndex )
  throw( sdbc::SQLException,
         uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    util::Time  Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<util::Time>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

util::DateTime SAL_CALL
XRow_impl::getTimestamp(
            sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
    throw sdbc::SQLException();
  util::DateTime  Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert<util::DateTime>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

uno::Reference< io::XInputStream > SAL_CALL
XRow_impl::getBinaryStream(
               sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
    throw sdbc::SQLException();
  uno::Reference< io::XInputStream >  Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert<uno::Reference< io::XInputStream > >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

uno::Reference< io::XInputStream > SAL_CALL
XRow_impl::getCharacterStream(
                  sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
  if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
      throw sdbc::SQLException();
  uno::Reference< io::XInputStream > Value;
  vos::OGuard aGuard( m_aMutex );
  m_nWasNull = ::convert< uno::Reference< io::XInputStream> >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
  return Value;
}

uno::Any SAL_CALL
XRow_impl::getObject(
    sal_Int32 columnIndex,
    const uno::Reference< container::XNameAccess >& )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Any  Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Any>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
    return Value;
}

uno::Reference< sdbc::XRef > SAL_CALL
XRow_impl::getRef(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XRef > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XRef> >( m_pMyShell,
                                                          m_xTypeConverter,
                                                          m_aValueMap[ --columnIndex ],
                                                          Value );
    return Value;
}

uno::Reference< sdbc::XBlob > SAL_CALL
XRow_impl::getBlob(
           sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XBlob > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XBlob> >( m_pMyShell,
                                                           m_xTypeConverter,
                                                           m_aValueMap[ --columnIndex ],
                                                           Value );
    return Value;
}

uno::Reference< sdbc::XClob > SAL_CALL
XRow_impl::getClob(
           sal_Int32 columnIndex )
  throw( sdbc::SQLException,
     uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XClob > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XClob> >( m_pMyShell,
                                                           m_xTypeConverter,
                                                           m_aValueMap[ --columnIndex ],
                                                           Value );
    return Value;
}

uno::Reference< sdbc::XArray > SAL_CALL
XRow_impl::getArray(
    sal_Int32 columnIndex )
    throw( sdbc::SQLException,
           uno::RuntimeException)
{
    if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
        throw sdbc::SQLException();
    uno::Reference< sdbc::XArray > Value;
    vos::OGuard aGuard( m_aMutex );
    m_nWasNull = ::convert<uno::Reference< sdbc::XArray> >( m_pMyShell,
                                                            m_xTypeConverter,
                                                            m_aValueMap[ --columnIndex ],
                                                            Value );
    return Value;
}
<|endoftext|>


<commit_before>#include "./NearBranchTrampoline.h"

#include "dobby_internal.h"

#include "NearMemoryArena.h"
#include "InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h"

using namespace zz;

void dobby_enable_near_branch_trampoline() {
  RoutingPlugin *plugin = new NearBranchTrampolinePlugin;
  ExtraInternalPlugin::registerPlugin("near_branch_trampoline", plugin);
  ExtraInternalPlugin::near_branch_trampoline = plugin;
}

void dobby_disable_near_branch_trampoline() {
  RoutingPlugin *plugin = (RoutingPlugin *)ExtraInternalPlugin::near_branch_trampoline;
  delete plugin;
  ExtraInternalPlugin::near_branch_trampoline = NULL;
}

#if 0
int NearBranchTrampolinePlugin::PredefinedTrampolineSize() {
#if __arm64__
  return 4;
#elif __arm__
  return 4;
#endif
}
#endif

extern CodeBufferBase *GenerateNearTrampolineBuffer(InterceptRouting *routing, addr_t from, addr_t to);
bool NearBranchTrampolinePlugin::GenerateTrampolineBuffer(InterceptRouting *routing, void *src, void *dst) {
  CodeBufferBase *trampoline_buffer;
  trampoline_buffer = GenerateNearTrampolineBuffer(routing, (addr_t)src, (addr_t)dst);
  if (trampoline_buffer == NULL)
    return false;
  routing->SetTrampolineBuffer(trampoline_buffer);
  return true;
}

// generate trampoline, patch the original entry
bool NearBranchTrampolinePlugin::Active(InterceptRouting *routing) {
  addr_t src, dst;

  HookEntry *entry = routing->GetHookEntry();
  src              = (addr_t)entry->target_address;
  dst              = (addr_t)routing->GetTrampolineTarget();

  return true;
}
<commit_msg>[core] mark func as exported<commit_after>#include "./NearBranchTrampoline.h"

#include "dobby_internal.h"

#include "NearMemoryArena.h"
#include "InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h"

using namespace zz;

PUBLIC void dobby_enable_near_branch_trampoline() {
  RoutingPlugin *plugin = new NearBranchTrampolinePlugin;
  ExtraInternalPlugin::registerPlugin("near_branch_trampoline", plugin);
  ExtraInternalPlugin::near_branch_trampoline = plugin;
}

PUBLIC void dobby_disable_near_branch_trampoline() {
  RoutingPlugin *plugin = (RoutingPlugin *)ExtraInternalPlugin::near_branch_trampoline;
  delete plugin;
  ExtraInternalPlugin::near_branch_trampoline = NULL;
}

#if 0
int NearBranchTrampolinePlugin::PredefinedTrampolineSize() {
#if __arm64__
  return 4;
#elif __arm__
  return 4;
#endif
}
#endif

extern CodeBufferBase *GenerateNearTrampolineBuffer(InterceptRouting *routing, addr_t from, addr_t to);
bool NearBranchTrampolinePlugin::GenerateTrampolineBuffer(InterceptRouting *routing, void *src, void *dst) {
  CodeBufferBase *trampoline_buffer;
  trampoline_buffer = GenerateNearTrampolineBuffer(routing, (addr_t)src, (addr_t)dst);
  if (trampoline_buffer == NULL)
    return false;
  routing->SetTrampolineBuffer(trampoline_buffer);
  return true;
}

// generate trampoline, patch the original entry
bool NearBranchTrampolinePlugin::Active(InterceptRouting *routing) {
  addr_t src, dst;

  HookEntry *entry = routing->GetHookEntry();
  src              = (addr_t)entry->target_address;
  dst              = (addr_t)routing->GetTrampolineTarget();

  return true;
}
<|endoftext|>


<commit_before>#include "CPU.h"
#if defined(__x86_64__) || defined(__i386__)
#include <cpuid.h>
#endif
#include "Log.h"

#ifndef bit_AES
#define bit_AES (1 << 25)
#endif
#ifndef bit_AVX
#define bit_AVX (1 << 28)
#endif

namespace i2p
{
namespace cpu
{
	bool aesni = false;
	bool avx = false;

	void Detect()
	{
#if defined(__x86_64__) || defined(__i386__)
		int info[4];
		__cpuid(0, info[0], info[1], info[2], info[3]);
		if (info[0] >= 0x00000001) {
			__cpuid(0x00000001, info[0], info[1], info[2], info[3]);
			aesni = info[2] & bit_AES;  // AESNI
			avx = info[2] & bit_AVX;  // AVX
		}
#endif
		if(aesni)
		{
			LogPrint(eLogInfo, "AESNI enabled");
		}
		if(avx)
		{
			LogPrint(eLogInfo, "AVX enabled");
		}
	}
}
}
<commit_msg>Revert "define cpu_* if not set"<commit_after>#include "CPU.h"
#if defined(__x86_64__) || defined(__i386__)
#include <cpuid.h>
#endif
#include "Log.h"
namespace i2p
{
namespace cpu
{
	bool aesni = false;
	bool avx = false;

	void Detect()
	{
#if defined(__x86_64__) || defined(__i386__)
		int info[4];
		__cpuid(0, info[0], info[1], info[2], info[3]);
		if (info[0] >= 0x00000001) {
			__cpuid(0x00000001, info[0], info[1], info[2], info[3]);
			aesni = info[2] & bit_AES;  // AESNI
			avx = info[2] & bit_AVX;  // AVX
		}
#endif
		if(aesni)
		{
			LogPrint(eLogInfo, "AESNI enabled");
		}
		if(avx)
		{
			LogPrint(eLogInfo, "AVX enabled");
		}
	}
}
}
<|endoftext|>


<commit_before>#include "stdafx.h"
#include "AlembicWriteJob.h"
#include "AlembicImport.h"
//#include "AlembicGetInfo.h"
//#include "AlembicGetNodeFromIdentifier.h"
#include "AlembicTimeControl.h"
#include "AlembicFileNode.h"
#include "AlembicXform.h"
#include "AlembicCamera.h"
#include "AlembicPolyMesh.h"
#include "AlembicSubD.h"
#include "AlembicPoints.h"
#include "AlembicCurves.h"
//#include "AlembicNurbs.h"
#include "MetaData.h"
#include "AlembicValidateNameCmd.h"
#include <maya/MFnPlugin.h>
#include <maya/MDGMessage.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MPlug.h>
#include <maya/MFnStringData.h>

// IDs issues for this plugin are:
// 0x0011A100 - 0x0011A1FF
const MTypeId mTimeControlNodeId(0x0011A100);
const MTypeId mFileNodeId(0x0011A101);
const MTypeId mXformNodeId(0x0011A102);
const MTypeId mCameraNodeId(0x0011A103);
const MTypeId mPolyMeshNodeId(0x0011A104);
const MTypeId mSubDNodeId(0x0011A105);
const MTypeId mPolyMeshDeformNodeId(0x0011A106);
const MTypeId mSubDDeformNodeId(0x0011A107);
const MTypeId mPointsNodeId(0x0011A108);
const MTypeId mCurvesNodeId(0x0011A109);
const MTypeId mCurvesDeformNodeId(0x0011A110);
const MTypeId mCurvesLocatorNodeId(0x0011A111);

static MCallbackId deleteAllArchivesCallbackOnNewId = 0;
static MCallbackId deleteAllArchivesCallbackOnOpenId = 0;
static MCallbackId deleteAllArchivesCallbackOnExitId = 0;
static void deleteAllArchivesCallback( void* clientData )
{
   preDestructAllNodes();
   deleteAllArchives();
}

#ifdef _MSC_VER
  #define EC_EXPORT
#else
  #define EC_EXPORT extern "C"
#endif

void removeExocortexAlembicNode(MObject &node, void *clientData)
{
	MFnDependencyNode nodeFn(node);
	MObject fname = nodeFn.attribute("fileName");
	if (!fname.isNull())
	{
		MPlug attrFileName(nodeFn.object(), fname);
		if (!attrFileName.getValue(fname))
			return;
		delRefArchive(MFnStringData(fname).string());
	}

	fname = nodeFn.attribute("uv_fileName");
	if (!fname.isNull())
	{
		MPlug attrFileName(nodeFn.object(), fname);
		if (!attrFileName.getValue(fname))
			return;
		delRefArchive(MFnStringData(fname).string());
	}
	MGlobal::displayInfo(MString("Removal callback node: ") + nodeFn.name());
}

EC_EXPORT MStatus initializePlugin(MObject obj)
{
   const char * pluginVersion = "1.0";
   MFnPlugin plugin(obj, "ExocortexAlembicMaya", pluginVersion, "Any");

   MStatus status;

   // callbacks
   if (deleteAllArchivesCallbackOnNewId == 0)
      deleteAllArchivesCallbackOnNewId = MSceneMessage::addCallback( MSceneMessage::kBeforeNew, deleteAllArchivesCallback );
   if (deleteAllArchivesCallbackOnOpenId == 0)
      deleteAllArchivesCallbackOnOpenId = MSceneMessage::addCallback( MSceneMessage::kBeforeOpen, deleteAllArchivesCallback );
   if (deleteAllArchivesCallbackOnExitId == 0)
      deleteAllArchivesCallbackOnExitId = MSceneMessage::addCallback( MSceneMessage::kMayaExiting, deleteAllArchivesCallback );

   // commands
   status = plugin.registerCommand("ExocortexAlembic_export",
      AlembicExportCommand::creator,
      AlembicExportCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_import",
      AlembicImportCommand::creator,
      AlembicImportCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_resolvePath",
      AlembicResolvePathCommand::creator,
      AlembicResolvePathCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_createMetaData",
      AlembicCreateMetaDataCommand::creator,
      AlembicCreateMetaDataCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_createFaceSets",
      AlembicCreateFaceSetsCommand::creator,
      AlembicCreateFaceSetsCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_assignFaceSets",
      AlembicAssignFacesetCommand::creator,
      AlembicAssignFacesetCommand::createSyntax);

   status = plugin.registerCommand("ExocortexAlembic_postImportPoints",
      AlembicPostImportPointsCommand::creator,
      AlembicPostImportPointsCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileBegin",
	  AlembicProfileBeginCommand::creator,
      AlembicProfileBeginCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileEnd",
	  AlembicProfileEndCommand::creator,
      AlembicProfileEndCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileStats",
	    AlembicProfileStatsCommand::creator,
      AlembicProfileStatsCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileReset",
	    AlembicProfileResetCommand::creator,
      AlembicProfileResetCommand::createSyntax);
	status = plugin.registerCommand("ExocortexAlembic_meshToSubdiv", AlembicPolyMeshToSubdivCommand::creator, AlembicPolyMeshToSubdivCommand::createSyntax);

   // nodes
   status = plugin.registerNode("ExocortexAlembicTimeControl",
      mTimeControlNodeId,
      &AlembicTimeControlNode::creator,
      &AlembicTimeControlNode::initialize);
   status = plugin.registerNode("ExocortexAlembicFile",
      mFileNodeId,
      &AlembicFileNode::creator,
      &AlembicFileNode::initialize);
   status = plugin.registerNode("ExocortexAlembicXform",
      mXformNodeId,
      &AlembicXformNode::creator,
      &AlembicXformNode::initialize);
   status = plugin.registerNode("ExocortexAlembicCamera",
      mCameraNodeId,
      &AlembicCameraNode::creator,
      &AlembicCameraNode::initialize);
   status = plugin.registerNode("ExocortexAlembicPolyMesh",
      mPolyMeshNodeId,
      &AlembicPolyMeshNode::creator,
      &AlembicPolyMeshNode::initialize);
   status = plugin.registerNode("ExocortexAlembicSubD",
      mSubDNodeId,
      &AlembicSubDNode::creator,
      &AlembicSubDNode::initialize);
   status = plugin.registerNode("ExocortexAlembicPolyMeshDeform",
      mPolyMeshDeformNodeId,
      &AlembicPolyMeshDeformNode::creator,
      &AlembicPolyMeshDeformNode::initialize,
      MPxNode::kDeformerNode);
   status = plugin.registerNode("ExocortexAlembicSubDDeform",
      mSubDDeformNodeId,
      &AlembicSubDDeformNode::creator,
      &AlembicSubDDeformNode::initialize,
      MPxNode::kDeformerNode);
   status = plugin.registerNode("ExocortexAlembicPoints",
      mPointsNodeId,
      &AlembicPointsNode::creator,
      &AlembicPointsNode::initialize,
      MPxNode::kEmitterNode);
   status = plugin.registerNode("ExocortexAlembicCurves",
      mCurvesNodeId,
      &AlembicCurvesNode::creator,
      &AlembicCurvesNode::initialize);
   status = plugin.registerNode("ExocortexAlembicCurvesDeform",
      mCurvesDeformNodeId,
      &AlembicCurvesDeformNode::creator,
      &AlembicCurvesDeformNode::initialize,
      MPxNode::kDeformerNode);
   status = plugin.registerNode("ExocortexAlembicCurvesLocator",
      mCurvesLocatorNodeId,
      &AlembicCurvesLocatorNode::creator,
      &AlembicCurvesLocatorNode::initialize,
      MPxNode::kLocatorNode);

   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicXform", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicCamera", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicPolyMesh", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicSubD", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicPolyMeshDeform", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicSubDDeform", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicPoints", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicCurves", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicCurvesDeform", NULL, &status);

   // Load the menu!
   MString cmd = "source \"menu.mel\"; exocortexAlembicLoadMenu(\"" + plugin.name() + "\");";
   MStatus commandStatus = MGlobal::executeCommand(cmd, true, false);
   if (commandStatus != MStatus::kSuccess)
   {
	  //EC_LOG_ERROR("FAILED TO SOURCE ../scripts/menu.mel: " << commandStatus.errorString());
   }

   commandStatus = MGlobal::executePythonCommand("import ExocortexAlembic as ExoAlembic\n");
   if (commandStatus != MStatus::kSuccess)
	   MGlobal::displayError("Unable to import ExocortexAlembic");
   MGlobal::executePythonCommand("import maya.cmds as __cmds__\n");

   EC_LOG_INFO( "Exocortex Crate "<<crate_MAJOR_VERSION<<"."<<crate_MINOR_VERSION<<"."<<crate_BUILD_VERSION );
   return status;
}

EC_EXPORT MStatus uninitializePlugin(MObject obj)
{
   MFnPlugin plugin(obj);

   // Unload the menu!
   MStatus commandStatus = MGlobal::executeCommand("source \"menu.mel\"; exocortexAlembicUnloadMenu;", true, false);
   if (commandStatus != MStatus::kSuccess)
   {
	  //EC_LOG_ERROR("FAILED TO SOURCE ../scripts/menu.mel: " << commandStatus.errorString());
   }

   MStatus status;

   if (deleteAllArchivesCallbackOnNewId)
   {
      MMessage::removeCallback( deleteAllArchivesCallbackOnNewId );
      deleteAllArchivesCallbackOnNewId = 0;
   }
   if (deleteAllArchivesCallbackOnOpenId)
   {
      MMessage::removeCallback( deleteAllArchivesCallbackOnOpenId );
      deleteAllArchivesCallbackOnOpenId = 0;
   }
   if (deleteAllArchivesCallbackOnExitId)
   {
      MMessage::removeCallback( deleteAllArchivesCallbackOnExitId );
      deleteAllArchivesCallbackOnExitId = 0;
   }

   status = plugin.deregisterCommand("ExocortexAlembic_export");
   status = plugin.deregisterCommand("ExocortexAlembic_getInfo");
   status = plugin.deregisterCommand("ExocortexAlembic_resolvePath");
   status = plugin.deregisterCommand("ExocortexAlembic_createMetaData");
   status = plugin.deregisterCommand("ExocortexAlembic_createFaceSets");

   status = plugin.deregisterNode(mTimeControlNodeId);
   status = plugin.deregisterNode(mFileNodeId);
   status = plugin.deregisterNode(mXformNodeId);
   status = plugin.deregisterNode(mCameraNodeId);
   status = plugin.deregisterNode(mPolyMeshNodeId);
   status = plugin.deregisterNode(mSubDNodeId);
   status = plugin.deregisterNode(mPolyMeshDeformNodeId);
   status = plugin.deregisterNode(mSubDDeformNodeId);
   status = plugin.deregisterNode(mPointsNodeId);
   status = plugin.deregisterNode(mCurvesNodeId);
   status = plugin.deregisterNode(mCurvesDeformNodeId);
   status = plugin.deregisterNode(mCurvesLocatorNodeId);

   return status;
}
<commit_msg>removed some printed messages!<commit_after>#include "stdafx.h"
#include "AlembicWriteJob.h"
#include "AlembicImport.h"
//#include "AlembicGetInfo.h"
//#include "AlembicGetNodeFromIdentifier.h"
#include "AlembicTimeControl.h"
#include "AlembicFileNode.h"
#include "AlembicXform.h"
#include "AlembicCamera.h"
#include "AlembicPolyMesh.h"
#include "AlembicSubD.h"
#include "AlembicPoints.h"
#include "AlembicCurves.h"
//#include "AlembicNurbs.h"
#include "MetaData.h"
#include "AlembicValidateNameCmd.h"
#include <maya/MFnPlugin.h>
#include <maya/MDGMessage.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MPlug.h>
#include <maya/MFnStringData.h>

// IDs issues for this plugin are:
// 0x0011A100 - 0x0011A1FF
const MTypeId mTimeControlNodeId(0x0011A100);
const MTypeId mFileNodeId(0x0011A101);
const MTypeId mXformNodeId(0x0011A102);
const MTypeId mCameraNodeId(0x0011A103);
const MTypeId mPolyMeshNodeId(0x0011A104);
const MTypeId mSubDNodeId(0x0011A105);
const MTypeId mPolyMeshDeformNodeId(0x0011A106);
const MTypeId mSubDDeformNodeId(0x0011A107);
const MTypeId mPointsNodeId(0x0011A108);
const MTypeId mCurvesNodeId(0x0011A109);
const MTypeId mCurvesDeformNodeId(0x0011A110);
const MTypeId mCurvesLocatorNodeId(0x0011A111);

static MCallbackId deleteAllArchivesCallbackOnNewId = 0;
static MCallbackId deleteAllArchivesCallbackOnOpenId = 0;
static MCallbackId deleteAllArchivesCallbackOnExitId = 0;
static void deleteAllArchivesCallback( void* clientData )
{
   preDestructAllNodes();
   deleteAllArchives();
}

#ifdef _MSC_VER
  #define EC_EXPORT
#else
  #define EC_EXPORT extern "C"
#endif

void removeExocortexAlembicNode(MObject &node, void *clientData)
{
	MFnDependencyNode nodeFn(node);
	MObject fname = nodeFn.attribute("fileName");
	if (!fname.isNull())
	{
		MPlug attrFileName(nodeFn.object(), fname);
		if (attrFileName.getValue(fname))
			delRefArchive(MFnStringData(fname).string());
	}

	fname = nodeFn.attribute("uv_fileName");
	if (!fname.isNull())
	{
		MPlug attrFileName(nodeFn.object(), fname);
		if (attrFileName.getValue(fname))
			delRefArchive(MFnStringData(fname).string());
	}
}

EC_EXPORT MStatus initializePlugin(MObject obj)
{
   const char * pluginVersion = "1.0";
   MFnPlugin plugin(obj, "ExocortexAlembicMaya", pluginVersion, "Any");

   MStatus status;

   // callbacks
   if (deleteAllArchivesCallbackOnNewId == 0)
      deleteAllArchivesCallbackOnNewId = MSceneMessage::addCallback( MSceneMessage::kBeforeNew, deleteAllArchivesCallback );
   if (deleteAllArchivesCallbackOnOpenId == 0)
      deleteAllArchivesCallbackOnOpenId = MSceneMessage::addCallback( MSceneMessage::kBeforeOpen, deleteAllArchivesCallback );
   if (deleteAllArchivesCallbackOnExitId == 0)
      deleteAllArchivesCallbackOnExitId = MSceneMessage::addCallback( MSceneMessage::kMayaExiting, deleteAllArchivesCallback );

   // commands
   status = plugin.registerCommand("ExocortexAlembic_export",
      AlembicExportCommand::creator,
      AlembicExportCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_import",
      AlembicImportCommand::creator,
      AlembicImportCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_resolvePath",
      AlembicResolvePathCommand::creator,
      AlembicResolvePathCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_createMetaData",
      AlembicCreateMetaDataCommand::creator,
      AlembicCreateMetaDataCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_createFaceSets",
      AlembicCreateFaceSetsCommand::creator,
      AlembicCreateFaceSetsCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_assignFaceSets",
      AlembicAssignFacesetCommand::creator,
      AlembicAssignFacesetCommand::createSyntax);

   status = plugin.registerCommand("ExocortexAlembic_postImportPoints",
      AlembicPostImportPointsCommand::creator,
      AlembicPostImportPointsCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileBegin",
	  AlembicProfileBeginCommand::creator,
      AlembicProfileBeginCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileEnd",
	  AlembicProfileEndCommand::creator,
      AlembicProfileEndCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileStats",
	    AlembicProfileStatsCommand::creator,
      AlembicProfileStatsCommand::createSyntax);
   status = plugin.registerCommand("ExocortexAlembic_profileReset",
	    AlembicProfileResetCommand::creator,
      AlembicProfileResetCommand::createSyntax);
	status = plugin.registerCommand("ExocortexAlembic_meshToSubdiv", AlembicPolyMeshToSubdivCommand::creator, AlembicPolyMeshToSubdivCommand::createSyntax);

   // nodes
   status = plugin.registerNode("ExocortexAlembicTimeControl",
      mTimeControlNodeId,
      &AlembicTimeControlNode::creator,
      &AlembicTimeControlNode::initialize);
   status = plugin.registerNode("ExocortexAlembicFile",
      mFileNodeId,
      &AlembicFileNode::creator,
      &AlembicFileNode::initialize);
   status = plugin.registerNode("ExocortexAlembicXform",
      mXformNodeId,
      &AlembicXformNode::creator,
      &AlembicXformNode::initialize);
   status = plugin.registerNode("ExocortexAlembicCamera",
      mCameraNodeId,
      &AlembicCameraNode::creator,
      &AlembicCameraNode::initialize);
   status = plugin.registerNode("ExocortexAlembicPolyMesh",
      mPolyMeshNodeId,
      &AlembicPolyMeshNode::creator,
      &AlembicPolyMeshNode::initialize);
   status = plugin.registerNode("ExocortexAlembicSubD",
      mSubDNodeId,
      &AlembicSubDNode::creator,
      &AlembicSubDNode::initialize);
   status = plugin.registerNode("ExocortexAlembicPolyMeshDeform",
      mPolyMeshDeformNodeId,
      &AlembicPolyMeshDeformNode::creator,
      &AlembicPolyMeshDeformNode::initialize,
      MPxNode::kDeformerNode);
   status = plugin.registerNode("ExocortexAlembicSubDDeform",
      mSubDDeformNodeId,
      &AlembicSubDDeformNode::creator,
      &AlembicSubDDeformNode::initialize,
      MPxNode::kDeformerNode);
   status = plugin.registerNode("ExocortexAlembicPoints",
      mPointsNodeId,
      &AlembicPointsNode::creator,
      &AlembicPointsNode::initialize,
      MPxNode::kEmitterNode);
   status = plugin.registerNode("ExocortexAlembicCurves",
      mCurvesNodeId,
      &AlembicCurvesNode::creator,
      &AlembicCurvesNode::initialize);
   status = plugin.registerNode("ExocortexAlembicCurvesDeform",
      mCurvesDeformNodeId,
      &AlembicCurvesDeformNode::creator,
      &AlembicCurvesDeformNode::initialize,
      MPxNode::kDeformerNode);
   status = plugin.registerNode("ExocortexAlembicCurvesLocator",
      mCurvesLocatorNodeId,
      &AlembicCurvesLocatorNode::creator,
      &AlembicCurvesLocatorNode::initialize,
      MPxNode::kLocatorNode);

   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicXform", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicCamera", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicPolyMesh", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicSubD", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicPolyMeshDeform", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicSubDDeform", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicPoints", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicCurves", NULL, &status);
   MDGMessage::addNodeRemovedCallback(removeExocortexAlembicNode, "ExocortexAlembicCurvesDeform", NULL, &status);

   // Load the menu!
   MString cmd = "source \"menu.mel\"; exocortexAlembicLoadMenu(\"" + plugin.name() + "\");";
   MStatus commandStatus = MGlobal::executeCommand(cmd, true, false);
   if (commandStatus != MStatus::kSuccess)
   {
	  //EC_LOG_ERROR("FAILED TO SOURCE ../scripts/menu.mel: " << commandStatus.errorString());
   }

   commandStatus = MGlobal::executePythonCommand("import ExocortexAlembic as ExoAlembic\n");
   if (commandStatus != MStatus::kSuccess)
	   MGlobal::displayError("Unable to import ExocortexAlembic");
   MGlobal::executePythonCommand("import maya.cmds as __cmds__\n");

   EC_LOG_INFO( "Exocortex Crate "<<crate_MAJOR_VERSION<<"."<<crate_MINOR_VERSION<<"."<<crate_BUILD_VERSION );
   return status;
}

EC_EXPORT MStatus uninitializePlugin(MObject obj)
{
   MFnPlugin plugin(obj);

   // Unload the menu!
   MStatus commandStatus = MGlobal::executeCommand("source \"menu.mel\"; exocortexAlembicUnloadMenu;", true, false);
   if (commandStatus != MStatus::kSuccess)
   {
	  //EC_LOG_ERROR("FAILED TO SOURCE ../scripts/menu.mel: " << commandStatus.errorString());
   }

   MStatus status;

   if (deleteAllArchivesCallbackOnNewId)
   {
      MMessage::removeCallback( deleteAllArchivesCallbackOnNewId );
      deleteAllArchivesCallbackOnNewId = 0;
   }
   if (deleteAllArchivesCallbackOnOpenId)
   {
      MMessage::removeCallback( deleteAllArchivesCallbackOnOpenId );
      deleteAllArchivesCallbackOnOpenId = 0;
   }
   if (deleteAllArchivesCallbackOnExitId)
   {
      MMessage::removeCallback( deleteAllArchivesCallbackOnExitId );
      deleteAllArchivesCallbackOnExitId = 0;
   }

   status = plugin.deregisterCommand("ExocortexAlembic_export");
   status = plugin.deregisterCommand("ExocortexAlembic_getInfo");
   status = plugin.deregisterCommand("ExocortexAlembic_resolvePath");
   status = plugin.deregisterCommand("ExocortexAlembic_createMetaData");
   status = plugin.deregisterCommand("ExocortexAlembic_createFaceSets");

   status = plugin.deregisterNode(mTimeControlNodeId);
   status = plugin.deregisterNode(mFileNodeId);
   status = plugin.deregisterNode(mXformNodeId);
   status = plugin.deregisterNode(mCameraNodeId);
   status = plugin.deregisterNode(mPolyMeshNodeId);
   status = plugin.deregisterNode(mSubDNodeId);
   status = plugin.deregisterNode(mPolyMeshDeformNodeId);
   status = plugin.deregisterNode(mSubDDeformNodeId);
   status = plugin.deregisterNode(mPointsNodeId);
   status = plugin.deregisterNode(mCurvesNodeId);
   status = plugin.deregisterNode(mCurvesDeformNodeId);
   status = plugin.deregisterNode(mCurvesLocatorNodeId);

   return status;
}
<|endoftext|>


<commit_before>#include "algebra.h"
#include <vector>
#include <cmath>

std::tuple<bool,int,int,int,int> algebra::quad_factor(int a, int b, int c) {
		// factors ax^2 + bx + c into (mx + n)(rx + s)
		// returns (factorable,m,n,r,s)
		auto f = std::tuple<bool,int,int,int,int>();
		float d = discriminant(a,b,c);
		if (!is_square_number(d)) {
			std::get<0>(f) = false;
			return f;
		}

		int sqrt_d = std::sqrt(d);
		// p and q are two integers whose product is ac
		// and whose sum is b
		int p = (b + sqrt_d) / 2;
		int q = (b - sqrt_d) / 2;
		int gcd_a_p = algebra::gcd(a,p);
		int gcd_q_c = algebra::gcd(q,c);

		if (a < 0) {gcd_a_p *= -1;}
		if (q < 0) {gcd_q_c *= -1;}
		std::get<0>(f) = true;
		std::get<1>(f) = gcd_a_p;
		std::get<2>(f) = gcd_q_c;
		std::get<3>(f) = a / gcd_a_p;
		std::get<4>(f) = p / gcd_a_p;
		return f;
}

std::map<std::string,int> algebra::expand(std::map<std::string,int> sum1, std::map<std::string,int>sum2) {
	std::map<std::string,int> product;
	for (auto pair1 : sum1) {
		std::string var1 = pair1.first;
		for (auto pair2 : sum2) {
			std::string var2 = pair2.first;
			std::string compound_var;
			if (var1 == var2) {
				if (var1 == "") {compound_var = "";}
				else {compound_var = var1 + "^2";}
			}
			else {
				// canonical order
				if (var1 < var2) {compound_var = var1 + var2;}
				else {compound_var = var2 + var1;}
			}
			product[compound_var] += pair1.second * pair2.second;
		}
	}
	return product;
}

int signum(int x) {
	if (x < 0) return -1;
	if (x > 0) return 1;
	return 0;
}

std::string algebra::factorization_to_string(std::tuple<bool,int,int,int,int> f) {
	if (std::get<0>(f) == false) {
		return "unfactorable";
	} else {
		// (mx + n)(rx + s)
		int m = std::get<1>(f);
		int n = std::get<2>(f);
		int r = std::get<3>(f);
		int s = std::get<4>(f);

		return "(" + line_to_string(m,"x",n) + ")("
				+ line_to_string(r,"x",s) + ")";
	}
}

std::string algebra::term_to_string(int coeff, std::string var) {
	switch (coeff) {
		case 1:
		return var;
		case -1:
		return "-" + var;
		default:
		return std::to_string(coeff) + var;
	}
}

std::string algebra::product_to_string(const std::string &a, const std:: string &b) {
	if (a == "1") {return b;}
	if (b == "1") {return a;}
	if (a == b) {return a + "^2";}
	return a + "*" + b;
}

std::string algebra::line_to_string(int coeff, std::string var, int constant) {
	std::string s = term_to_string(coeff,var);
	if (constant > 0) {
		return s + " + " + std::to_string(constant);
	}
	if (constant == 0) {
		return s;
	} else {
		return s + " - " + std::to_string(-1 * constant);
	}
}

std::string algebra::sum_to_string(std::map<std::string,int> var_coeff_map) {
	if (var_coeff_map.empty()) {return "0";}
	auto it = var_coeff_map.begin();
	auto end = var_coeff_map.end();
	std::string out{};
	if (it->second != 0) {
		out += algebra::term_to_string(it->second,it->first);
	}
	++it;
	while (it != end) {
		if (it->second > 0) {
			out += " + ";
			out += algebra::term_to_string(it->second,it->first);
		}
		if (it->second < 0) {
			out += " - ";
			out += algebra::term_to_string(-1*(it->second),it->first);
		}
		++it;
	}

	if (out.empty()) {return "0";}
	else {return out;}
}

std::string algebra::enclose(std::string expr) {
	expr.insert(expr.begin(),'(');
	expr.push_back(')');
	return expr;
}

float algebra::discriminant(float a, float b, float c) {
	return b * b - 4 * a * c;
}

bool algebra::is_square_number(int n) {
	if (n < 0) {return false;}
	int floored_root = std::floor(std::sqrt(n));
	return floored_root * floored_root == n;
}

int algebra::gcd(int a, int b) {
	return std::get<0>(gcd_ext(a,b));
}

std::tuple<int,int,int> algebra::gcd_ext(int a, int b) {
	std::vector<int> q = {0};
	std::vector<int> r = {a,b};
	std::vector<int> s = {1,0};
	std::vector<int> t = {0,1};
	int i = 1;
	while (r[i] != 0) {
		auto qr = algebra::fdiv_qr(r[i-1],r[i]);
		q.push_back(std::get<0>(qr));
		r.push_back(std::get<1>(qr));
		s.push_back(s[i-1] - q[i] * s[i]);
		t.push_back(t[i-1] - q[i] * t[i]);
		++i;
	}

	// normalize gcd, s, t
	if (r[i-1] < 0) {
		return std::tuple<int,int,int>(-1 * r[i-1],-1 * s[i-1],-1 * t[i-1]);
	} else {
		return std::tuple<int,int,int>(r[i-1],s[i-1],t[i-1]);
	}
}

// floored division
// returns (quotient, remainder)
std::tuple<int,int> algebra::fdiv_qr(int a, int b) {
	int q = a / b;
	if ((q < 0) && (q * b != a)) {
		q -= 1;
	}
	int r = a - q * b;
	return std::tuple<int,int>(q, r);
}

// truncated division
std::tuple<int,int> algebra::tdiv_qr(int a, int b) {
	int q = a / b;
	int r = a - q * b;
	return std::tuple<int,int>(q,r);
}<commit_msg>minor fixes<commit_after>#include "algebra.h"
#include <vector>
#include <cmath>

std::tuple<bool,int,int,int,int> algebra::quad_factor(int a, int b, int c) {
		// factors ax^2 + bx + c into (mx + n)(rx + s)
		// returns (factorable,m,n,r,s)
		auto f = std::tuple<bool,int,int,int,int>();
		float d = discriminant(a,b,c);
		if (!is_square_number(d)) {
			std::get<0>(f) = false;
			return f;
		}

		int sqrt_d = std::sqrt(d);
		// p and q are two integers whose product is ac
		// and whose sum is b
		int p = (b + sqrt_d) / 2;
		int q = (b - sqrt_d) / 2;
		int gcd_a_p = algebra::gcd(a,p);
		int gcd_q_c = algebra::gcd(q,c);

		if (a < 0) {gcd_a_p *= -1;}
		if (q < 0) {gcd_q_c *= -1;}
		std::get<0>(f) = true;
		std::get<1>(f) = gcd_a_p;
		std::get<2>(f) = gcd_q_c;
		std::get<3>(f) = a / gcd_a_p;
		std::get<4>(f) = p / gcd_a_p;
		return f;
}

std::map<std::string,int> algebra::expand(std::map<std::string,int> sum1, std::map<std::string,int>sum2) {
	std::map<std::string,int> product;
	for (auto pair1 : sum1) {
		std::string var1 = pair1.first;
		for (auto pair2 : sum2) {
			std::string var2 = pair2.first;
			std::string compound_var;
			if (var1 == var2) {
				if (var1 == "") {compound_var = "";}
				else {compound_var = var1 + "^2";}
			}
			else {
				// canonical order
				if (var1 < var2) {compound_var = var1 + var2;}
				else {compound_var = var2 + var1;}
			}
			product[compound_var] += pair1.second * pair2.second;
		}
	}
	return product;
}

int signum(int x) {
	if (x < 0) return -1;
	if (x > 0) return 1;
	return 0;
}

std::string algebra::factorization_to_string(std::tuple<bool,int,int,int,int> f) {
	if (std::get<0>(f) == false) {
		return "unfactorable";
	} else {
		// (mx + n)(rx + s)
		int m = std::get<1>(f);
		int n = std::get<2>(f);
		int r = std::get<3>(f);
		int s = std::get<4>(f);

		return "(" + line_to_string(m,"x",n) + ")("
				+ line_to_string(r,"x",s) + ")";
	}
}

std::string algebra::term_to_string(int coeff, std::string var) {
	if (var == "") {return std::to_string(coeff);}
	switch (coeff) {
		case 0:
		return "0";
		case 1:
		return var;
		case -1:
		return "-" + var;
		default:
		return std::to_string(coeff) + var;
	}
}

std::string algebra::product_to_string(const std::string &a, const std:: string &b) {
	if (a == "1") {return b;}
	if (b == "1") {return a;}
	if (a == b) {return a + "^2";}
	return a + "*" + b;
}

std::string algebra::line_to_string(int coeff, std::string var, int constant) {
	if (coeff == 0) {return std::to_string(constant);}
	std::string s = term_to_string(coeff,var);
	if (constant > 0) {
		return s + " + " + std::to_string(constant);
	}
	if (constant == 0) {
		return s;
	} else {
		return s + " - " + std::to_string(-1 * constant);
	}
}

std::string algebra::sum_to_string(std::map<std::string,int> var_coeff_map) {
	if (var_coeff_map.empty()) {return "0";}
	auto it = var_coeff_map.begin();
	auto end = var_coeff_map.end();
	std::string out{};
	if (it->second != 0) {
		out += algebra::term_to_string(it->second,it->first);
	}
	++it;
	while (it != end) {
		if (it->second > 0) {
			out += " + ";
			out += algebra::term_to_string(it->second,it->first);
		}
		if (it->second < 0) {
			out += " - ";
			out += algebra::term_to_string(-1*(it->second),it->first);
		}
		++it;
	}

	if (out.empty()) {return "0";}
	else {return out;}
}

std::string algebra::enclose(std::string expr) {
	expr.insert(expr.begin(),'(');
	expr.push_back(')');
	return expr;
}

float algebra::discriminant(float a, float b, float c) {
	return b * b - 4 * a * c;
}

bool algebra::is_square_number(int n) {
	if (n < 0) {return false;}
	int floored_root = std::floor(std::sqrt(n));
	return floored_root * floored_root == n;
}

int algebra::gcd(int a, int b) {
	return std::get<0>(gcd_ext(a,b));
}

std::tuple<int,int,int> algebra::gcd_ext(int a, int b) {
	std::vector<int> q = {0};
	std::vector<int> r = {a,b};
	std::vector<int> s = {1,0};
	std::vector<int> t = {0,1};
	int i = 1;
	while (r[i] != 0) {
		auto qr = algebra::fdiv_qr(r[i-1],r[i]);
		q.push_back(std::get<0>(qr));
		r.push_back(std::get<1>(qr));
		s.push_back(s[i-1] - q[i] * s[i]);
		t.push_back(t[i-1] - q[i] * t[i]);
		++i;
	}

	// normalize gcd, s, t
	if (r[i-1] < 0) {
		return std::tuple<int,int,int>(-1 * r[i-1],-1 * s[i-1],-1 * t[i-1]);
	} else {
		return std::tuple<int,int,int>(r[i-1],s[i-1],t[i-1]);
	}
}

// floored division
// returns (quotient, remainder)
std::tuple<int,int> algebra::fdiv_qr(int a, int b) {
	int q = a / b;
	if ((q < 0) && (q * b != a)) {
		q -= 1;
	}
	int r = a - q * b;
	return std::tuple<int,int>(q, r);
}

// truncated division
std::tuple<int,int> algebra::tdiv_qr(int a, int b) {
	int q = a / b;
	int r = a - q * b;
	return std::tuple<int,int>(q,r);
}<|endoftext|>