示例#1
0
文件: cibutil.cpp 项目: satya-das/cib
std::string longName(const CppFwdClsDecl* fwdCls)
{
  if (isCppFile(fwdCls->owner()))
    return "::" + fwdCls->name_;
  else
    return longName(fwdCls->owner()) + "::" + fwdCls->name_;
}
示例#2
0
MStatus PRTAttrs::addColorParameter(MFnDependencyNode & node, MObject & attr, const MString & name, MString & value ) {
	MStatus             stat;
	MFnNumericAttribute nAttr;

	const wchar_t* s = value.asWChar();

	attr = nAttr.createColor(longName(name), briefName(name), &stat );
	MCHECK(stat);

	double r = 0.0;
	double g = 0.0;
	double b = 0.0;

	if (s[0] == '#' && wcslen(s) >= 7) {
		r = (double)((prtu::fromHex(s[1]) << 4) + prtu::fromHex(s[2])) / 255.0;
		g = (double)((prtu::fromHex(s[3]) << 4) + prtu::fromHex(s[4])) / 255.0;
		b = (double)((prtu::fromHex(s[5]) << 4) + prtu::fromHex(s[6])) / 255.0;

		nAttr.setDefault(r, g, b);
	}

	MCHECK(addParameter(node, attr, nAttr));

	MFnNumericData fnData;
	MObject        rgb = fnData.create(MFnNumericData::k3Double, &stat);
	MCHECK(stat);

	fnData.setData(r, g, b);
	MPlug plug(node.object(), attr);
	MCHECK(plug.setValue(rgb));

	return MS::kSuccess;
}
示例#3
0
int ArgumentScanner::scanLongOption(const QStringList& args, int startIndex)
{
    const auto& arg = args[startIndex];
    if (arg.length() < 4 || !arg.startsWith("--") || '-' == arg[2])
        return 0;

    auto name = arg.mid(2);
    QString val = QString::null;

    int assignIndex = name.indexOf('=');
    if (assignIndex >= 0)
    {
        val = name.mid(assignIndex + 1);
        name = name.left(assignIndex);
    }
    if (name.length() < 2)
        return 0;

    Token longName(Token::LONGNAME, name);
    m_tokens.push_back(longName);

    if (assignIndex < 0)
        return 1;

    Token assign(Token::ASSIGN);
    m_tokens.push_back(assign);

    Token value(Token::OTHER, val);
    m_tokens.push_back(value);

    return 1;
}
示例#4
0
void ABundleAttribute::getNumericAttrib(ANumericAttribute * & dst) const
{
    switch (numericType() ) {
        case TByteNumeric:
            dst = new AByteNumericAttribute;
            break;
        case TShortNumeric:
            dst = new AShortNumericAttribute;
            break;
        case TIntNumeric:
            dst = new AIntNumericAttribute;
            break;
        case TFloatNumeric:
            dst = new AFloatNumericAttribute;
            break;
        case TDoubleNumeric:
            dst = new ADoubleNumericAttribute;
            break;
        case TBooleanNumeric:
            dst = new ABooleanNumericAttribute;
            break;
        default:
            break;
    }
    
    if(!dst)
        return;
        
    dst->setShortName(shortName() );
    dst->setLongName(longName() );
}
示例#5
0
QString BitcoinUnits::shortName(int unit)
{
    switch(unit)
    {
    case uBTC: return QString::fromUtf8("bits");
    default:   return longName(unit);
    }
}
QString DigiByteUnits::shortName(int unit)
{
    switch(unit)
    {
    case uDGB: return QString::fromUtf8("bits");
    case SAT: return QString("sat");
    default: return longName(unit);
    }
}
QString MachinecoinUnits::shortName(int unit)
{
    switch(unit)
    {
    case uMAC: return QString::fromUtf8("bits");
    case SAT: return QString("sat");
    default: return longName(unit);
    }
}
示例#8
0
bool Arguments::evaluate(int argc, char* argv[])
{
  // parse program arguments
  vector<string> args(argv + 1, argv + argc);

  bool is_valid = true;
  errors_.clear();

  for (auto i = options_.begin(); i != options_.end(); ++i) { // configured options
    auto option = i->second;
    bool found = false;

    for (auto j = args.begin(); j != args.end(); ++j) { // given arguments
      string arg_name  = *j;

      stringstream aux;
      aux << "-" << option->shortName();

      string opt_short = aux.str();
      string opt_long  = "--" + option->longName();

      if ((option->hasShortName() && arg_name == opt_short) || (arg_name == opt_long)) {
        if (!option->isFlag()) {
          option->value(*++j);
        }

        found = true;
      }
    }

    if (!found && option->required()) {
      stringstream ss;
      ss << "Option \"" << option->longName() << "\" is required!" << endl;
      errors_ = ss.str();

      is_valid = false;
      break;
    }
  }

  return is_valid;
}
示例#9
0
MStatus PRTAttrs::addBoolParameter(MFnDependencyNode & node, MObject & attr, const MString & name, bool value) {
	MStatus stat;
	MFnNumericAttribute nAttr;
	attr = nAttr.create(longName(name), briefName(name), MFnNumericData::kBoolean, value, &stat);
	if ( stat != MS::kSuccess ) throw stat;

	MCHECK(addParameter(node, attr, nAttr));

	MPlug plug(node.object(), attr);
	MCHECK(plug.setValue(value));

	return MS::kSuccess;
}
示例#10
0
MStatus PRTAttrs::addStrParameter(MFnDependencyNode & node, MObject & attr, const MString & name, MString & value ) {
	MStatus           stat;
	MStatus           stat2;
	MFnStringData		  stringData;
	MFnTypedAttribute sAttr;

	attr = sAttr.create(longName(name), briefName(name), MFnData::kString, stringData.create(value, &stat2), &stat );
	MCHECK(stat2);
	MCHECK(stat);
	MCHECK(addParameter(node, attr, sAttr));

	MPlug plug(node.object(), attr);
	MCHECK(plug.setValue(value));

	return MS::kSuccess;
}
示例#11
0
MStatus PRTAttrs::addEnumParameter(MFnDependencyNode & node, MObject & attr, const MString & name, short value, PRTEnum * e) {


	MStatus stat;

	attr = e->mAttr.create(longName(name), briefName(name), value, &stat);
	MCHECK(stat);

	MCHECK(e->fill());

	MCHECK(addParameter(node, attr, e->mAttr));

	MPlug plug(node.object(), attr);
	MCHECK(plug.setValue(value));

	return MS::kSuccess;
}
示例#12
0
void PageTemplate::write(QXmlStreamWriter *xml)
{
    QLocale locale;
    QString thisLanguage = locale.name().split('_').at(0);

    xml->writeStartElement("page-template");
    xml->writeAttribute("name",name());
    if( !isHalfOf().isEmpty() )
        xml->writeAttribute("is-half-of",isHalfOf());

    xml->writeStartElement("long-name");
    xml->writeAttribute("lang",thisLanguage);
    xml->writeCharacters(longName());
    xml->writeEndElement(); // long-name
    for(int i=0; i<aOtherLongNames.count(); i++)
    {
        xml->writeStartElement("long-name");
        xml->writeAttribute("lang",aOtherLongNames.at(i).lang);
        xml->writeCharacters(aOtherLongNames.at(i).string);
        xml->writeEndElement(); // long-name
    }

    xml->writeTextElement("width",QString::number(width()));
    xml->writeTextElement("height",QString::number(height()));
    xml->writeTextElement("header",QString::number(header()));
    xml->writeTextElement("footer",QString::number(footer()));

    xml->writeStartElement("margins");
    xml->writeAttribute("side","right");
    xml->writeTextElement("left-margin",QString::number(leftMargin(Book::Right)));
    xml->writeTextElement("right-margin",QString::number(rightMargin(Book::Right)));
    xml->writeTextElement("top-margin",QString::number(topMargin(Book::Right)));
    xml->writeTextElement("bottom-margin",QString::number(bottomMargin(Book::Right)));
    xml->writeEndElement(); // margins

    xml->writeStartElement("margins");
    xml->writeAttribute("side","left");
    xml->writeTextElement("left-margin",QString::number(leftMargin(Book::Left)));
    xml->writeTextElement("right-margin",QString::number(rightMargin(Book::Left)));
    xml->writeTextElement("top-margin",QString::number(topMargin(Book::Left)));
    xml->writeTextElement("bottom-margin",QString::number(bottomMargin(Book::Left)));
    xml->writeEndElement(); // margins

    xml->writeEndElement(); // page-template
}
示例#13
0
QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
{
    int row = index.row();
    if(row >= 0 && row < unitlist.size())
    {
        Unit unit = unitlist.at(row);
        switch(role)
        {
        case Qt::EditRole:
        case Qt::DisplayRole:
            return QVariant(longName(unit));
        case Qt::ToolTipRole:
            return QVariant(description(unit));
        case UnitRole:
            return QVariant(static_cast<int>(unit));
        }
    }
    return QVariant();
}
示例#14
0
void
ObjModelLoader::parseMtl(fs::path file)
{
	//TODO parse Mtl-File and put the materials into the (hash)map
	// within the model.
	// remember: 1 object = 1 material = 1 vbo
	// mööööp  -wrong!
	if (!exists(file))
		cerr << "Material-File '" << file.string() << "' does not exist!"
				<< endl;

	Material* matPtr = 0;
	fs::ifstream mtlFile;
	mtlFile.open(file, ios::in);

	char line[200];
	vector<string> tokens;
	while (mtlFile.getline(line, 200)) {
		tokens = splitSpace(string(line));
		if (tokens[0] == ("newmtl")) {
			string longName("");
			for (unsigned int i = 1; i < tokens.size(); ++i) {
				longName.append(tokens[i]);
				longName.append(" ");
			}
			longName.erase(longName.end() - 1);
			matPtr = new Material();
			matPtr->kdR = ooctools::defaultColorF.getX();
			matPtr->kdG = ooctools::defaultColorF.getY();
			matPtr->kdB = ooctools::defaultColorF.getZ();
			mPriMatMap.insert(make_pair(longName, matPtr));
			//			cout << "found MaterialDefinition '" << tokens[1] << "'!" << endl;
		}
		else if (!strcasecmp("kd", tokens[0].c_str())) {
			matPtr->kdR = atof(tokens[1].c_str());
			matPtr->kdG = atof(tokens[2].c_str());
			matPtr->kdB = atof(tokens[3].c_str());
		}
	}
	mtlFile.close();
}
示例#15
0
MStatus PRTAttrs::addFloatParameter(MFnDependencyNode & node, MObject & attr, const MString & name, double value, double min, double max) {
	MStatus stat;
	MFnNumericAttribute nAttr;
	attr = nAttr.create(longName(name), briefName(name), MFnNumericData::kDouble, value, &stat );
	if ( stat != MS::kSuccess ) throw stat;

	if(!isnan(min)) {
		MCHECK(nAttr.setMin(min));
	}

	if(!isnan(max)) {
		MCHECK(nAttr.setMax( max ));
	}

	MCHECK(addParameter(node, attr, nAttr));

	MPlug plug(node.object(), attr);
	MCHECK(plug.setValue(value));

	return MS::kSuccess;
}
示例#16
0
void test_suffix() {
  ok(!w_string("").suffix(), "empty string suffix");
  ok(w_string(".").suffix() == w_string(""), "only one dot suffix");
  ok(w_string("endwithdot.").suffix() == w_string(""), "end with dot");
  ok(!w_string("nosuffix").suffix(), "no suffix");
  ok(w_string(".beginwithdot").suffix() == w_string("beginwithdot"),
     "begin with dot");
  ok(w_string("MainActivity.java").suffix() == w_string("java"), "java suffix");

  std::string longName(128, 'a');
  auto str = w_string::build(".", longName.c_str());
  ok(!str.suffix(), "too long suffix");

  std::string nearlongName(127, 'a');
  str = w_string::build("I am not long enough.", nearlongName.c_str());
  ok(str.suffix().size() == 127, "nearly too long suffix");

  // 255 is the longest suffix among some systems
  std::string toolongName(255, 'a');
  str = w_string::build(".", toolongName.c_str());
  ok(!str.suffix(), "too long suffix");
}
示例#17
0
文件: cibutil.cpp 项目: satya-das/cib
std::string longName(const CppObj* typeObj)
{
  switch (typeObj->objType_)
  {
    case CppObjType::kEnum:
      return longName(static_cast<const CppEnum*>(typeObj));
    case CppObjType::kTypedefName:
      return longName(static_cast<const CppTypedefName*>(typeObj));
    case CppObjType::kUsingDecl:
      return longName(static_cast<const CppUsingDecl*>(typeObj));
    case CppObjType::kFunctionPtr:
      return longName(static_cast<const CppFunctionPtr*>(typeObj));
    case CppObjType::kCompound:
      return longName(static_cast<const CibCompound*>(typeObj));
    case CppObjType::kFwdClsDecl:
      return longName(static_cast<const CppFwdClsDecl*>(typeObj));

    default:
      assert(false && "May be we need more case above");
      return "";
  }
}
示例#18
0
bool QOption::isValid() const
{
    return !shortName().isEmpty() || !longName().isEmpty();
}
示例#19
0
void
ObjModelLoader::secondPass()
{
	string lastType = "";
	int grpId = -1;
	mPriModelPtr->setCurrentGrp(mPriModelPtr->getGrpStart()->first);

	fs::path my_path(mPriFName);
	fs::ifstream objFile;
	objFile.open(my_path, ios::out);
	char line[200];
	vector<string> tokens;
	while (objFile.getline(line, 200)) {
		tokens = splitSpace(string(line));
		if (tokens[0] == ("g")) {
//			removeSpecialCharsFromName(tokens[1]);
			++grpId;
			lastType = "g";
			string longname("");
			for (unsigned int i = 1; i < tokens.size(); ++i) {
				longname.append(tokens[i]);
				longname.append("_");
			}
			longname.erase(longname.end() - 1);

			mPriModelPtr->setCurrentGrp(longname);
			//cout << _model.getCurrentGrpPtr()->name << endl;
		}
		else if (tokens[0] == ("v")) {
			lastType = "v";
		}
		// moved material assignment to 2nd pass because it references a group.
		// But only at end of 1st pass we know our groups
		else if (tokens[0] == ("usemtl")) {
			//			cout << "found material reference " << tokens[1] << " in obj-file" << endl;
			string longName("");
			for (unsigned int i = 1; i < tokens.size(); ++i) {
				longName.append(tokens[i]);
				longName.append(" ");
			}
			longName.erase(longName.end() - 1);
			if (mPriMatMap.find(longName) != mPriMatMap.end())
				mPriModelPtr->getCurrentGrpPtr()->setMat(*mPriMatMap[longName]);
			lastType = "usemtl";
		}
		else if (tokens[0] == ("f")) {
			//cout << "Number of Components per face: " << tokens.size()-1 << endl;
			Face* f = new Face();
			f->norm = false;
			f->vert = false;
			f->matIdx = 0;
			f->tex = 0;
			f->fNormal = 0;

			string::size_type loc = tokens[1].find("/", 0);
			if (loc != string::npos) {
				for (string::size_type i = 1; i < tokens.size(); ++i) {
					vector<int> comp = extractFaceComponents(tokens[i]);
					// vertices
					if ((comp[0] & 4)) {
						V3f* vtx = mPriModelPtr->getVPtr(comp[1] - 1);
						f->vertexPtrList.push_back(vtx);
						vtx->addFaceRef(f);
						f->vert = true;
						mPriModelPtr->getCurrentGrpPtr()->nVertices++;
						mPriModelPtr->incVCount();
						mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx);
					}
					// textures
					if ((comp[0] & 2)) {
						f->texturePtrList.push_back(mPriModelPtr->getTPtr(
								comp[2] - 1));
						++f->tex;
						mPriModelPtr->getCurrentGrpPtr()->nTextureCoords++;
						mPriModelPtr->incTCount();
					}
					// normals
					if ((comp[0] & 1)) {
						f->normalPtrList.push_back(mPriModelPtr->getNPtr(
								comp[3] - 1));
						f->norm = true;
						mPriModelPtr->getCurrentGrpPtr()->nNormals++;
						mPriModelPtr->incNCount();
					}
					comp.clear();
				}
			}
			else {
				V3f* vtx = mPriModelPtr->getVPtr(atoi(tokens[1].c_str()) - 1);
				f->vertexPtrList.push_back(vtx);
				mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx);
				vtx = mPriModelPtr->getVPtr(atoi(tokens[2].c_str()) - 1);
				f->vertexPtrList.push_back(vtx);
				mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx);
				vtx = mPriModelPtr->getVPtr(atoi(tokens[3].c_str()) - 1);
				f->vertexPtrList.push_back(vtx);
				mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx);
				f->vert = true;
				mPriModelPtr->getCurrentGrpPtr()->nVertices += 3;
				mPriModelPtr->incVCount(3);

			}
			mPriModelPtr->addFPtrToCurrent(f);
			lastType = "f";
		}
	}
	objFile.close();
}