当前位置: 首页>>代码示例>>C++>>正文


C++ Variant函数代码示例

本文整理汇总了C++中Variant函数的典型用法代码示例。如果您正苦于以下问题:C++ Variant函数的具体用法?C++ Variant怎么用?C++ Variant使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Variant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getValue

Variant ArrayData::current() const {
  return m_pos != invalid_index ? getValue(m_pos) : Variant(false);
}
开发者ID:jbinfo,项目名称:hiphop-php,代码行数:3,代码来源:array-data.cpp

示例2: Variant

Variant ArrayPair::key(VariableEnvironment &env) const {
  if (m_key) {
    return m_key->eval(env);
  }
  return Variant();
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:6,代码来源:array_expression.cpp

示例3: CV_Assert

Variant BlendMultiband::exec() {
	std::vector< cv::Mat* >* matIn = NULL; // CV_32FC3 - ARRAY
	std::vector< cv::Mat* >* matOut = NULL; // CV_32FC3 - SCALAR
	std::vector< cv::Mat* >* matSelect = NULL; // CV_32FC3 - ARRAY

	{
		if (this->workspaceHandle.count(std::string("matIn")) == 1) {
			matIn = this->workspaceHandle[std::string("matIn")];
		}

		if (this->workspaceHandle.count(std::string("matOut")) == 1) {
			matOut = this->workspaceHandle[std::string("matOut")];
		}

		if (this->workspaceHandle.count(std::string("matSelect")) == 1) {
			matSelect = this->workspaceHandle[std::string("matSelect")];
		}

		CV_Assert(matIn == NULL || matIn->size() == 0 || matIn->at(0)->empty() == true || matIn->at(0)->type() == CV_32FC3);
		CV_Assert(matOut == NULL || matOut->size() == 0 || matOut->at(0)->empty() == true || matOut->at(0)->type() == CV_32FC3);
		CV_Assert(matSelect == NULL || matSelect->size() == 0 || matSelect->at(0)->empty() == true || matSelect->at(0)->type() == CV_32FC3);
	}

	std::string strImplementation = std::string("CUSTOM");

	{
		if (this->settingsHandle.count(std::string("strImplementation")) == 1) {
			strImplementation = this->settingsHandle[std::string("strImplementation")].getString();
		}
	}

	int intDepth = 4;

	{
		if (this->settingsHandle.count(std::string("intDepth")) == 1) {
			intDepth = this->settingsHandle[std::string("intDepth")].getInt();
		}
	}

	int intInterpolation = cv::INTER_LINEAR;

	{
		if (this->settingsHandle.count(std::string("strInterpolation")) == 1) {
			if (this->settingsHandle[std::string("strInterpolation")].getString() == std::string("NEAREST")) {
				intInterpolation = cv::INTER_NEAREST;

			} else if (this->settingsHandle[std::string("strInterpolation")].getString() == std::string("LINEAR")) {
				intInterpolation = cv::INTER_LINEAR;

			} else if (this->settingsHandle[std::string("strInterpolation")].getString() == std::string("CUBIC")) {
				intInterpolation = cv::INTER_CUBIC;

			} else if (this->settingsHandle[std::string("strInterpolation")].getString() == std::string("AREA")) {
				intInterpolation = cv::INTER_AREA;

			} else if (this->settingsHandle[std::string("strInterpolation")].getString() == std::string("LANCZOS")) {
				intInterpolation = cv::INTER_LANCZOS4;

			}
		}
	}

	if (strImplementation == std::string("OPENCV")) {
		cv::Ptr< cv::detail::Blender > blenderHandle = cv::detail::Blender::createDefault(cv::detail::Blender::MULTI_BAND, false);

		{
			cv::detail::MultiBandBlender* multibandblenderHandle = (cv::detail::MultiBandBlender*) (blenderHandle.get());

			multibandblenderHandle->setNumBands(intDepth);
		}

		{
			blenderHandle->prepare(cv::Rect(0.0, 0.0, System::obtain()->intWidth, System::obtain()->intHeight));
		}

		{
			for (int intFor1 = 0; intFor1 < matIn->size(); intFor1 += 1) {
				cv::Mat matHandle[2] = { };

				{
					cv::multiply(*matIn->at(intFor1), cv::Scalar(255, 255, 255), matHandle[0], 1.0, CV_16SC3);
				}

				{
					cv::Mat matTemp = cv::Mat();

					cv::deflate(*matSelect->at(intFor1), matTemp, 1);

					cv::compare(matTemp, cv::Scalar(0.999), matHandle[1], cv::CMP_GT);

					cv::multiply(matHandle[1], cv::Scalar(255), matHandle[1], 1.0, CV_8UC1);
				}

				{
					blenderHandle->feed(matHandle[0], matHandle[1], cv::Point(0, 0));
				}

				{
					System::obtain()->execProgress(this->strName, matIn->size(), intFor1 + 1);
				}
//.........这里部分代码省略.........
开发者ID:CodeRect,项目名称:OpenFuse,代码行数:101,代码来源:BlendMultiband.cpp

示例4: _jobject_to_variant

Variant _jobject_to_variant(JNIEnv * env, jobject obj) {

	jclass c = env->GetObjectClass(obj);
	bool array;
	String name = _get_class_name(env, c, &array);
	//print_line("name is " + name + ", array "+Variant(array));

	if (name == "java.lang.String") {

		return String::utf8(env->GetStringUTFChars( (jstring)obj, NULL ));
	};


	if (name == "[Ljava.lang.String;") {

		jobjectArray arr = (jobjectArray)obj;
		int stringCount = env->GetArrayLength(arr);
		//print_line("String array! " + String::num(stringCount));
		DVector<String> sarr;

		for (int i=0; i<stringCount; i++) {
			jstring string = (jstring) env->GetObjectArrayElement(arr, i);
			const char *rawString = env->GetStringUTFChars(string, 0);
			sarr.push_back(String(rawString));
		}

		return sarr;
	};

	if (name == "java.lang.Boolean") {

		jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
		bool ret = env->CallBooleanMethod(obj, boolValue);
		return ret;
	};

	if (name == "java.lang.Integer") {

		jclass nclass = env->FindClass("java/lang/Number");
		jmethodID intValue = env->GetMethodID(nclass, "intValue", "()I");
		int ret = env->CallIntMethod(obj, intValue);
		return ret;
	};

	if (name == "[I") {

		jintArray arr = (jintArray)obj;
		int fCount = env->GetArrayLength(arr);
		DVector<int> sarr;
		sarr.resize(fCount);

		DVector<int>::Write w = sarr.write();
		env->GetIntArrayRegion(arr,0,fCount,w.ptr());
		w = DVector<int>::Write();
		return sarr;
	};

	if (name == "java.lang.Float" || name == "java.lang.Double") {

		jclass nclass = env->FindClass("java/lang/Number");
		jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
		double ret = env->CallDoubleMethod(obj, doubleValue);
		return ret;
	};

	if (name == "[D") {

		jdoubleArray arr = (jdoubleArray)obj;
		int fCount = env->GetArrayLength(arr);
		RealArray sarr;
		sarr.resize(fCount);

		RealArray::Write w = sarr.write();

		for (int i=0; i<fCount; i++) {

			double n;
			env->GetDoubleArrayRegion(arr, i, 1, &n);
			w.ptr()[i] = n;

		};
		return sarr;
	};

	if (name == "[F") {

		jfloatArray arr = (jfloatArray)obj;
		int fCount = env->GetArrayLength(arr);
		RealArray sarr;
		sarr.resize(fCount);


		RealArray::Write w = sarr.write();

		for (int i=0; i<fCount; i++) {

			float n;
			env->GetFloatArrayRegion(arr, i, 1, &n);
			w.ptr()[i] = n;

//.........这里部分代码省略.........
开发者ID:19Staceys,项目名称:godot,代码行数:101,代码来源:java_glue.cpp

示例5: Array_to_mono_array

MonoArray *godot_icall_String_md5_buffer(MonoString *p_str) {
	Vector<uint8_t> ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_buffer();
	// TODO Check possible Array/Vector<uint8_t> problem?
	return GDMonoMarshal::Array_to_mono_array(Variant(ret));
}
开发者ID:Paulloz,项目名称:godot,代码行数:5,代码来源:string_glue.cpp

示例6: switch

Variant Deserializer::ReadVariant(VariantType type)
{
    switch (type)
    {
    case VAR_INT:
        return Variant(ReadInt());
        
    case VAR_BOOL:
        return Variant(ReadBool());
        
    case VAR_FLOAT:
        return Variant(ReadFloat());
        
    case VAR_VECTOR2:
        return Variant(ReadVector2());
        
    case VAR_VECTOR3:
        return Variant(ReadVector3());
        
    case VAR_VECTOR4:
        return Variant(ReadVector4());
        
    case VAR_QUATERNION:
        return Variant(ReadQuaternion());
        
    case VAR_COLOR:
        return Variant(ReadColor());
        
    case VAR_STRING:
        return Variant(ReadString());
        
    case VAR_BUFFER:
        return Variant(ReadBuffer());
        
        // Deserializing pointers is not supported. Return null
    case VAR_VOIDPTR:
    case VAR_PTR:
        ReadUInt();
        return Variant((void*)0);
        
    case VAR_RESOURCEREF:
        return Variant(ReadResourceRef());
        
    case VAR_RESOURCEREFLIST:
        return Variant(ReadResourceRefList());
        
    case VAR_VARIANTVECTOR:
        return Variant(ReadVariantVector());
        
    case VAR_VARIANTMAP:
        return Variant(ReadVariantMap());
        
    case VAR_INTRECT:
        return Variant(ReadIntRect());
        
    case VAR_INTVECTOR2:
        return Variant(ReadIntVector2());
        
    case VAR_MATRIX3:
        return Variant(ReadMatrix3());
        
    case VAR_MATRIX3X4:
        return Variant(ReadMatrix3x4());
        
    case VAR_MATRIX4:
        return Variant(ReadMatrix4());
        
    default:
        return Variant();
    }
}
开发者ID:1vanK,项目名称:Urho3DQuake2,代码行数:71,代码来源:Deserializer.cpp

示例7: _xml_characterDataHandler

void _xml_characterDataHandler(void *userData, const XML_Char *s, int len) {
  auto parser = getParserFromToken(userData);

  if (parser) {
    Variant retval;
    Array args = Array::Create();

    if (parser->characterDataHandler.toBoolean()) {
      args.append(Variant(parser));
      args.append(_xml_xmlchar_zval(s, len, parser->target_encoding));
      xml_call_handler(parser, parser->characterDataHandler, args);
    }

    if (!parser->data.isNull()) {
      int i;
      int doprint = 0;

      String decoded_value;
      int decoded_len;
      decoded_value = xml_utf8_decode(s,len,
                                          parser->target_encoding);
      decoded_len = decoded_value.size();
      for (i = 0; i < decoded_len; i++) {
        switch (decoded_value[i]) {
        case ' ':
        case '\t':
        case '\n':
        default:
          doprint = 1;
          break;
        }
        if (doprint) {
          break;
        }
      }
      if (doprint || (! parser->skipwhite)) {
        if (parser->lastwasopen) {
          String myval;
          // check if value exists, if yes append to that
          if (parser->ctag.toArrRef().exists(s_value)) {
            myval = parser->ctag.toArray().rvalAt(s_value).toString();
            myval += decoded_value;
            parser->ctag.toArrRef().set(s_value, myval);
          } else {
            parser->ctag.toArrRef().set(
              s_value,
              decoded_value
            );
          }
        } else {
          Array tag;
          String myval;
          String mytype;

          auto curtag = parser->data.toArrRef().pop();
          SCOPE_EXIT {
            try {
              parser->data.toArrRef().append(curtag);
            } catch (...) {}
          };

          if (curtag.toArrRef().exists(s_type)) {
            mytype = curtag.toArrRef().rvalAt(s_type).toString();
            if (!strcmp(mytype.data(), "cdata") &&
                curtag.toArrRef().exists(s_value)) {
              myval = curtag.toArrRef().rvalAt(s_value).toString();
              myval += decoded_value;
              curtag.toArrRef().set(s_value, myval);
              return;
            }
          }
          if (parser->level <= XML_MAXLEVEL) {
            tag = Array::Create();
            _xml_add_to_info(parser, parser->ltags[parser->level-1] +
                             parser->toffset);
            tag.set(s_tag, String(parser->ltags[parser->level-1] +
                                  parser->toffset, CopyString));
            tag.set(s_value, decoded_value);
            tag.set(s_type, s_cdata);
            tag.set(s_level, parser->level);
            parser->data.toArrRef().append(tag);
          } else if (parser->level == (XML_MAXLEVEL + 1)) {
            raise_warning("Maximum depth exceeded - Results truncated");
          }
        }
      }
    }
  }
开发者ID:RavenB,项目名称:hhvm,代码行数:88,代码来源:ext_xml.cpp

示例8: ERR_FAIL_COND_V

Variant Object::_call_bind(const StringName& p_name, const Variant& p_arg1, const Variant& p_arg2, const Variant& p_arg3, const Variant& p_arg4) {

	ERR_FAIL_COND_V(p_argcount<1,Variant());

	return call(p_name, p_arg1, p_arg2, p_arg3, p_arg4);
};
开发者ID:Brickcaster,项目名称:godot,代码行数:6,代码来源:object.cpp

示例9: Variant

Variant Object::getvar(const Variant& p_key, bool *r_valid) const {

	if (r_valid)
		*r_valid=false;
	return Variant();
}
开发者ID:Brickcaster,项目名称:godot,代码行数:6,代码来源:object.cpp

示例10: Variant

Variant CanvasItem::edit_get_state() const {


	return Variant();
}
开发者ID:AMG194,项目名称:godot,代码行数:5,代码来源:canvas_item.cpp

示例11: getKind

Array TypeAnnotation::getScalarArrayRep() const {
  auto rep = Array::Create();

  bool nullable = (bool) m_nullable;
  if (nullable) {
    rep.add(s_nullable, true_varNR);
  }

  bool allowsUnknownFields = (bool) m_allowsUnknownFields;
  if (allowsUnknownFields) {
    rep.add(s_allows_unknown_fields, true_varNR);
  }

  TypeStructure::Kind kind = getKind();
  rep.add(s_kind, Variant(static_cast<uint8_t>(kind)));

  switch (kind) {
  case TypeStructure::Kind::T_tuple:
    assert(m_typeArgs);
    rep.add(s_elem_types, Variant(argsListToScalarArray(m_typeArgs)));
    break;
  case TypeStructure::Kind::T_fun:
    assert(m_typeArgs);
    // return type is the first of the typeArgs
    rep.add(s_return_type, Variant(m_typeArgs->getScalarArrayRep()));
    rep.add(s_param_types,
            Variant(argsListToScalarArray(m_typeArgs->m_typeList)));
    break;
  case TypeStructure::Kind::T_array:
  case TypeStructure::Kind::T_dict:
  case TypeStructure::Kind::T_vec:
  case TypeStructure::Kind::T_keyset:
    if (m_typeArgs) {
      rep.add(s_generic_types, Variant(argsListToScalarArray(m_typeArgs)));
    }
    break;
  case TypeStructure::Kind::T_shape:
    shapeFieldsToScalarArray(rep, m_typeArgs);
    break;
  case TypeStructure::Kind::T_typevar:
    rep.add(s_name, Variant(m_name));
    break;
  case TypeStructure::Kind::T_typeaccess: {
    // for now, only store the vanilla names (strings) as part of the
    // access list
    rep.add(s_root_name, Variant(m_name));
    auto accList = Array::Create();
    auto typeEl = m_typeArgs;
    int i = 0;
    while (typeEl) {
      accList.add(i, Variant(typeEl->vanillaName()));
      ++i;
      typeEl = typeEl->m_typeList;
    }
    rep.add(s_access_list, Variant(accList));
    break;
  }
  case TypeStructure::Kind::T_xhp:
    rep.add(s_classname, Variant(m_name));
    break;
  case TypeStructure::Kind::T_unresolved:
    rep.add(s_classname, Variant(m_name));
    if (m_typeArgs) {
      rep.add(s_generic_types, Variant(argsListToScalarArray(m_typeArgs)));
    }
    break;
  default:
    break;
  }

  if (!m_generics.empty()) {
    rep.add(s_typevars, Variant(m_generics));
  }

  rep.setEvalScalar();
  return rep;
}
开发者ID:elgenie,项目名称:hiphop-php,代码行数:77,代码来源:type_annotation.cpp

示例12: print_line

bool EditorFileSystem::_check_missing_imported_files(const String &p_path) {

	if (!reimport_on_missing_imported_files)
		return true;

	Error err;
	FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);

	if (!f) {
		print_line("could not open import for " + p_path);
		return false;
	}

	VariantParser::StreamFile stream;
	stream.f = f;

	String assign;
	Variant value;
	VariantParser::Tag next_tag;

	int lines = 0;
	String error_text;

	List<String> to_check;

	while (true) {

		assign = Variant();
		next_tag.fields.clear();
		next_tag.name = String();

		err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
		if (err == ERR_FILE_EOF) {
			memdelete(f);
			return OK;
		} else if (err != OK) {
			ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
			memdelete(f);
			return false;
		}

		if (assign != String()) {
			if (assign.begins_with("path")) {
				to_check.push_back(value);
			} else if (assign == "files") {
				Array fa = value;
				for (int i = 0; i < fa.size(); i++) {
					to_check.push_back(fa[i]);
				}
			}

		} else if (next_tag.name != "remap" && next_tag.name != "deps") {
			break;
		}
	}

	memdelete(f);

	for (List<String>::Element *E = to_check.front(); E; E = E->next()) {
		if (!FileAccess::exists(E->get())) {
			print_line("missing " + E->get() + ", reimport");
			return false;
		}
	}
	return true;
}
开发者ID:rrrfffrrr,项目名称:godot,代码行数:66,代码来源:editor_file_system.cpp

示例13: Variant

        Variant &Variant::operator=(T &&rhs)
        {
            Variant( static_cast<T&&>( rhs ) ).Swap( *this );

            return *this;
        }
开发者ID:AustinBrunkhorst,项目名称:CPP-Reflection,代码行数:6,代码来源:Variant.hpp

示例14: ERR_EXPLAIN

Variant Object::call(const StringName& p_name, VARIANT_ARG_DECLARE) {
#if 0
	if (p_name==CoreStringNames::get_singleton()->_free) {
#ifdef DEBUG_ENABLED
		if (cast_to<Reference>()) {
			ERR_EXPLAIN("Can't 'free' a reference.");
			ERR_FAIL_V(Variant());
		}
#endif
		//must be here, must be before everything,
		memdelete(this);
		return Variant();
	}

	VARIANT_ARGPTRS;

	int argc=0;
	for(int i=0;i<VARIANT_ARG_MAX;i++) {
		if (argptr[i]->get_type()==Variant::NIL)
			break;
		argc++;
	}

	Variant::CallError error;

	Variant ret;

	if (script_instance) {
		ret = script_instance->call(p_name,argptr,argc,error);
		if (_test_call_error(p_name,error))
			return ret;
	}

	MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_name);

	if (method) {


		Variant ret = method->call(this,argptr,argc,error);
		if (_test_call_error(p_name,error))
			return ret;

		return ret;
	} else {

	}

	return Variant();
#else

	VARIANT_ARGPTRS;

	int argc=0;
	for(int i=0;i<VARIANT_ARG_MAX;i++) {
		if (argptr[i]->get_type()==Variant::NIL)
			break;
		argc++;
	}

	Variant::CallError error;

	Variant ret = call(p_name,argptr,argc,error);
	return ret;

#endif

}
开发者ID:Brickcaster,项目名称:godot,代码行数:67,代码来源:object.cpp

示例15: switch

bool Polygon2DEditor::forward_input_event(const InputEvent& p_event) {

	if (node==NULL)
		return false;

	switch(p_event.type) {

		case InputEvent::MOUSE_BUTTON: {

			const InputEventMouseButton &mb=p_event.mouse_button;

			Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();


			Vector2 gpoint = Point2(mb.x,mb.y);
			Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
			cpoint=canvas_item_editor->snap_point(cpoint);
			cpoint = node->get_global_transform().affine_inverse().xform(cpoint);


			Vector<Vector2> poly = Variant(node->get_polygon());

			//first check if a point is to be added (segment split)
			real_t grab_treshold=EDITOR_DEF("poly_editor/point_grab_radius",8);

			switch(mode) {


				case MODE_CREATE: {

					if (mb.button_index==BUTTON_LEFT && mb.pressed) {


						if (!wip_active) {

							wip.clear();
							wip.push_back( cpoint-node->get_offset() );
							wip_active=true;
							edited_point_pos=cpoint;
							canvas_item_editor->get_viewport_control()->update();
							edited_point=1;
							return true;
						} else {


							if (wip.size()>1 && xform.xform(wip[0]+node->get_offset()).distance_to(gpoint)<grab_treshold) {
								//wip closed
								_wip_close();

								return true;
							} else {

								wip.push_back( cpoint-node->get_offset() );
								edited_point=wip.size();
								canvas_item_editor->get_viewport_control()->update();
								return true;

								//add wip point
							}
						}
					} else if (mb.button_index==BUTTON_RIGHT && mb.pressed && wip_active) {
						_wip_close();
					}



				} break;

				case MODE_EDIT: {

					if (mb.button_index==BUTTON_LEFT) {
						if (mb.pressed) {

							if (mb.mod.control) {


								if (poly.size() < 3) {

									undo_redo->create_action("Edit Poly");
									undo_redo->add_undo_method(node,"set_polygon",poly);
									poly.push_back(cpoint);
									undo_redo->add_do_method(node,"set_polygon",poly);
									undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
									undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
									undo_redo->commit_action();
									return true;
								}

								//search edges
								int closest_idx=-1;
								Vector2 closest_pos;
								real_t closest_dist=1e10;
								for(int i=0;i<poly.size();i++) {

									Vector2 points[2] ={ xform.xform(poly[i]+node->get_offset()),
										xform.xform(poly[(i+1)%poly.size()]+node->get_offset()) };

									Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
									if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
										continue; //not valid to reuse point
//.........这里部分代码省略.........
开发者ID:AMG194,项目名称:godot,代码行数:101,代码来源:polygon_2d_editor_plugin.cpp


注:本文中的Variant函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。