本文整理汇总了C++中setter函数的典型用法代码示例。如果您正苦于以下问题:C++ setter函数的具体用法?C++ setter怎么用?C++ setter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ar
bool rs::jsapi::Object::Set(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) {
JSAutoRequest ar(cx);
auto state = Object::GetState(cx, obj);
if (state != nullptr && state->setter != nullptr) {
Value value(cx, vp);
char nameBuffer[256];
auto name = JSID_TO_STRING(id);
auto nameLength = JS_EncodeStringToBuffer(cx, name, nameBuffer, sizeof(nameBuffer) - 1);
try {
if (nameLength < sizeof(nameBuffer)) {
nameBuffer[nameLength] = '\0';
state->setter(nameBuffer, value);
} else {
std::vector<char> nameVector(nameLength + 1);
nameLength = JS_EncodeStringToBuffer(cx, name, &nameVector[0], nameVector.size() - 1);
nameVector[nameLength] = '\0';
state->setter(&nameVector[0], value);
}
return true;
} catch (const std::exception& ex) {
JS_ReportError(cx, ex.what());
return false;
}
} else {
// TODO: what will this do to the JS?
vp.setUndefined();
return true;
}
}
示例2: QWidget
MeshesTab::MeshesTab(QWidget *parent) : QWidget(parent) {
warnDisabledPickingCheck.setChecked(true);
warnDisabledPickingCheck.setToolTip(tr("Mesh picking is disabled if your graphics driver does not at least support OpenGL 3.0."));
visibilityGroupLayout.addWidget(&meshInOrthoVPsCheck);
visibilityGroupLayout.addWidget(&meshIn3DVPCheck);
visibilityGroup.setLayout(&visibilityGroupLayout);
static auto opacityControls = [this/* required for GCC8*/](auto & label, auto & slider, auto & spin, auto & layout, auto setter){
slider.setRange(0, 100);
slider.setOrientation(Qt::Horizontal);
spin.setRange(0, 1);
spin.setSingleStep(0.01);
spin.setPrefix("×");
layout.addWidget(&label);
layout.addWidget(&slider);
layout.addWidget(&spin);
QObject::connect(&spin, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [&slider, setter](const double value) {
{
QSignalBlocker blocker{slider};
slider.setValue(value * 100);
}
setter(value);
});
QObject::connect(&slider, static_cast<void(QSlider::*)(int)>(&QSlider::valueChanged), [&spin, setter](const int value) {
{
QSignalBlocker blocker{spin};
spin.setValue(value/100.);
}
setter(spin.value());
});
};
opacityControls(alphaLabel3d, alphaSlider3d, alphaSpin3d, alphaLayout, [](auto val){state->viewer->setMesh3dAlphaFactor(val);});
opacityControls(alphaLabelSlicing, alphaSliderSlicing, alphaSpinSlicing, alphaLayout, [](auto val){state->viewer->setMeshSlicingAlphaFactor(val);});
mainLayout.addWidget(&visibilityGroup);
for (auto * sep : {&separator1, &separator2}) {
sep->setFrameShape(QFrame::HLine);
sep->setFrameShadow(QFrame::Sunken);
}
mainLayout.addWidget(&separator1);
mainLayout.addLayout(&alphaLayout);
mainLayout.addWidget(&separator2);
mainLayout.addWidget(&warnDisabledPickingCheck);
mainLayout.setAlignment(Qt::AlignTop);
setLayout(&mainLayout);
QObject::connect(&meshInOrthoVPsCheck, &QCheckBox::clicked, [](const bool checked) { state->viewerState->meshDisplay.setFlag(TreeDisplay::ShowInOrthoVPs, checked); });
QObject::connect(&meshIn3DVPCheck, &QCheckBox::clicked, [](const bool checked) { state->viewerState->meshDisplay.setFlag(TreeDisplay::ShowIn3DVP, checked); });
QObject::connect(state->viewer, &Viewer::mesh3dAlphaFactorChanged, &alphaSpin3d, &QDoubleSpinBox::setValue);
QObject::connect(state->viewer, &Viewer::meshSlicingAlphaFactorChanged, &alphaSpinSlicing, &QDoubleSpinBox::setValue);
}
示例3: KSI_CTX_setUri
static int KSI_CTX_setUri(KSI_CTX *ctx,
const char *uri, const char *loginId, const char *key,
int (*setter)(KSI_NetworkClient*, const char*, const char *, const char *)){
int res = KSI_UNKNOWN_ERROR;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || uri == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
if (ctx->isCustomNetProvider){
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Unable to set url after initial network provider replacement.");
goto cleanup;
}
res = setter(ctx->netProvider, uri, loginId, key);
if (res != KSI_OK) {
KSI_pushError(ctx,res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例4: brute_nearest
void brute_nearest(DistanceCallback& dcb, const node<P>* query,
v_array<d_node<P> > zero_set, ScalarType* upper_bound,
v_array<v_array<P> > &results,
v_array<v_array<d_node<P> > > &spare_zero_sets)
{
if (query->num_children > 0)
{
v_array<d_node<P> > new_zero_set = pop(spare_zero_sets);
node<P> * query_chi = query->children;
brute_nearest(dcb, query_chi, zero_set, upper_bound, results, spare_zero_sets);
ScalarType* new_upper_bound = alloc_upper();
node<P> *child_end = query->children + query->num_children;
for (query_chi++;query_chi != child_end; query_chi++)
{
setter(new_upper_bound,*upper_bound + query_chi->parent_dist);
copy_zero_set(dcb, query_chi, new_upper_bound, zero_set, new_zero_set);
brute_nearest(dcb, query_chi, new_zero_set, new_upper_bound, results, spare_zero_sets);
}
free (new_upper_bound);
new_zero_set.index = 0;
push(spare_zero_sets, new_zero_set);
}
else
{
v_array<P> temp;
push(temp, query->p);
d_node<P> *end = zero_set.elements + zero_set.index;
for (d_node<P> *ele = zero_set.elements; ele != end ; ele++)
if (ele->dist <= *upper_bound)
push(temp, ele->n->p);
push(results,temp);
}
}
示例5: setter
nsresult
PeerConnectionMedia::UpdateMediaPipelines()
{
// The GMP code is all the way on the other side of webrtc.org, and it is not
// feasible to plumb error information all the way back. So, we set up a
// handle to the PC (for the duration of this call) in a global variable.
// This allows the GMP code to report errors to the PC.
WebrtcGmpPCHandleSetter setter(mParentHandle);
for (RefPtr<TransceiverImpl>& transceiver : mTransceivers) {
nsresult rv = transceiver->UpdateConduit();
if (NS_FAILED(rv)) {
return rv;
}
if (!transceiver->IsVideo()) {
rv = transceiver->SyncWithMatchingVideoConduits(mTransceivers);
if (NS_FAILED(rv)) {
return rv;
}
// TODO: If there is no audio, we should probably de-sync. However, this
// has never been done before, and it is unclear whether it is safe...
}
}
return NS_OK;
}
示例6: raw_match
void raw_match(Expr ptree, Expr arg, Env* env, Expr*(*setter)(Symbol,Env*)) {
switch(ptree.type) {
case IGNORE:
break;
case SYMBOL:
*setter(ptree.sym, env) = arg;
break;
case NIL:
if(arg.type != NIL)
error(L"Unmatched nil in parameter tree");
break;
case PAIR:
if(arg.type != PAIR)
error(L"Unmatched pair in parameter tree");
raw_match(ptree.pair[0], arg.pair[0], env, setter);
raw_match(ptree.pair[1], arg.pair[1], env, setter);
break;
default:
error(L"Unexpected type in parameter tree");
break;
}
}
示例7: setValue
void StringPropertyHandler::setValue(QString value)
{
if (QMetaObject::invokeMethod(_target, setter().constData(), QGenericArgument("QString", &value)))
{
_changed = true;
}
}
示例8: lqtL_newindexfunc
static int lqtL_newindexfunc (lua_State *L) {
if (!lua_isuserdata(L, 1) && lua_islightuserdata(L, 1)) return 0;
lua_getmetatable(L, 1);
lua_pushliteral(L, "__set");
lua_rawget(L, -2);
if (lua_istable(L, -1)) {
lua_pushvalue(L, 2);
lua_gettable(L, -2);
if (lua_isfunction(L, -1)) {
lua_CFunction setter = lua_tocfunction(L, -1);
if (!setter) return luaL_error(L, "Invalid setter %s", lua_tostring(L, 2));
return setter(L);
}
}
lua_settop(L, 3); // (=3)
lua_getfenv(L, 1); // (+1)
if (!lua_istable(L, -1)) {
lua_pop(L, 1); // (+0)
return 0;
}
lua_remove(L, 1); // (+0)
lua_insert(L, 1); // (+0)
lua_rawset(L, 1); // (-2)
return 0;
}
示例9: GET_FUNC
size_t TSimpleLemmer::CopyFromMystem(MystemAnalysesHandle* analyses, const Wtroka& src, TWLemmaArray& out) {
size_t count = GET_FUNC(Lib, MystemAnalysesCount)(analyses);
out.clear();
out.resize(count);
for (size_t i = 0; i != count; ++i) {
MystemLemmaHandle* lemma = GET_FUNC(Lib, MystemLemma)(analyses, i);
NLemmerAux::TSimpleLemmaSetter setter(out[i]);
setter.SetLemma(GET_FUNC(Lib, MystemLemmaText)(lemma),
GET_FUNC(Lib, MystemLemmaTextLen)(lemma),
GET_FUNC(Lib, MystemLemmaForm)(lemma),
GET_FUNC(Lib, MystemLemmaFormLen)(lemma),
GET_FUNC(Lib, MystemLemmaStemGram)(lemma),
GET_FUNC(Lib, MystemLemmaFlexGram)(lemma),
GET_FUNC(Lib, MystemLemmaFlexGramNum)(lemma),
GET_FUNC(Lib, MystemLemmaFlexLen)(lemma),
GET_FUNC(Lib, MystemLemmaRuleId)(lemma),
GET_FUNC(Lib, MystemLemmaQuality)(lemma),
src);
}
DeleteAnalyses(analyses);
return count;
}
示例10: KSI_CTX_setTimeoutSeconds
static int KSI_CTX_setTimeoutSeconds(KSI_CTX *ctx, int timeout, int (*setter)(KSI_NetworkClient*, int)){
int res = KSI_UNKNOWN_ERROR;
KSI_NetworkClient *client = NULL;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || ctx->netProvider == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
if (ctx->isCustomNetProvider){
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Unable to set timeout after initial network provider replacement.");
goto cleanup;
}
client = ctx->netProvider;
res = setter(client, timeout);
if (res != KSI_OK) {
KSI_pushError(ctx,res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例11: getAndSetIf
void getAndSetIf(bool conditionalValue, Function&& setter, Keys&&... keys) {
auto current = get<DataType, Traits>(keys...);
if (current == conditionalValue) {
current = not conditionalValue;
setter();
set<DataType, Traits>(current, std::forward<Keys>(keys)...);
}
}
示例12: setCouponPricer
void setCouponPricer(
const Leg& leg,
const boost::shared_ptr<FloatingRateCouponPricer>& pricer) {
PricerSetter setter(pricer);
for (Size i=0; i<leg.size(); ++i) {
leg[i]->accept(setter);
}
}
示例13: set_ttymode
static int
set_ttymode(int fd, conmode *t, void (*setter)(conmode *, void *), void *arg)
{
conmode r;
if (!getattr(fd, t)) return 0;
r = *t;
setter(&r, arg);
return setattr(fd, &r);
}
示例14: setter
void playsingle_controller::linger()
{
LOG_NG << "beginning end-of-scenario linger\n";
browse_ = true;
linger_ = true;
// If we need to set the status depending on the completion state
// the key to it is here.
gui_->set_game_mode(game_display::LINGER_SP);
// this is actually for after linger mode is over -- we don't
// want to stay stuck in linger state when the *next* scenario
// is over.
set_completion setter(gamestate_,"running");
// change the end-turn button text to its alternate label
gui_->get_theme().refresh_title2("button-endturn", "title2");
gui_->invalidate_theme();
gui_->redraw_everything();
// End all unit moves
for (unit_map::iterator u = units_.begin(); u != units_.end(); ++u) {
u->set_user_end_turn(true);
}
start_pass_scenario_anim(get_end_level_data().result);
try {
// Same logic as single-player human turn, but
// *not* the same as multiplayer human turn.
gui_->enable_menu("endturn", true);
while(!end_turn_) {
// Reset the team number to make sure we're the right team.
player_number_ = first_player_;
play_slice();
gui_->draw();
}
} catch(game::load_game_exception& lge) {
// Loading a new game is effectively a quit.
if (lge.game != "") {
gamestate_ = game_state();
}
throw lge;
}
if (gui_->pass_scenario_anim_id() != -1) {
gui_->erase_screen_anim(gui_->pass_scenario_anim_id());
}
// revert the end-turn button text to its normal label
gui_->get_theme().refresh_title2("button-endturn", "title");
gui_->invalidate_theme();
gui_->redraw_everything();
gui_->set_game_mode(game_display::RUNNING);
LOG_NG << "ending end-of-scenario linger\n";
}
示例15: addTag
void addTag(const char *tag, const QString& value) {
GstTagSetter *s = setter();
if (!s) {
return;
}
gst_tag_setter_add_tags(s, GST_TAG_MERGE_REPLACE, tag, value.toUtf8().data(), NULL);
gst_object_unref(s);
}