flags

Checking flag bits java

别来无恙 提交于 2019-11-27 07:23:19
I have a problem with flag bits. I have an int variable to hold flags. First I set some flags to that variable. Later I need check how many flags were set in that variable. But I don't know to do it. To check to see if a bit value is set: int value = VALUE_TO_CHECK | OTHER_VALUE_TO_CHECK; if ((value & VALUE_TO_CHECK) == VALUE_TO_CHECK) { // do something--it was set } if ((value & OTHER_VALUE_TO_CHECK) == OTHER_VALUE_TO_CHECK) { // also set (if it gets in here, then it was defined in // value, but it does not guarantee that it was set with // OR without other values. To guarantee it's only this

How do Integer flags work?

随声附和 提交于 2019-11-27 07:17:04
问题 I do not understand how flags work and would appreciate some help and a link to a tutorial to try and understand what is happening when adding values to an Integer as flags. For example, I am backing up various-sized files to an SD card. A lot of the files often already exist, so I first run through and check FileExists , FileAge , and size, and if appropriate, add it to the list to copy across with ShFileOperation . Using a routine by Peter Barlow from here it is working but I want to

How to query flags stored as enum in NHibernate

坚强是说给别人听的谎言 提交于 2019-11-27 06:25:27
问题 How to do either a HQL or a Criteria search (the latter is preferred) involving an enum that is used as flags. In other words, I have a persisted enum property that stores some kind of flags. I want to query all the records that have one of these flags set. Using Eq won't work of course because that will only be true, if that is the only flag set. Solving this using the Criteria API would be the best, but if this is only doable using HQL that is good too. 回答1: Here's how you could do it with

Activity stack ordering problem when launching application from Android app installer and from Home screen

五迷三道 提交于 2019-11-27 06:16:12
For testing purposes only, I am allowing my app APK to be downloaded and installed via a URL. Once downloaded on the phone, it can be launched with the Android app installer which gives the user an option to install it to their device and then run it. Consider if we downloaded and ran the app in the way described above. The main/launcher activity in my app is a login page ( Activity A ). Once the user is authenticated, they are taken to the main area of the application, e.g. Activity B . So now the current activity stack of this task is A > B . I then press the home button on the phone and am

How to check if any flags of a flag combination are set?

…衆ロ難τιáo~ 提交于 2019-11-27 06:11:48
Let's say I have this enum: [Flags] enum Letters { A = 1, B = 2, C = 4, AB = A | B, All = A | B | C, } To check if for example AB is set I can do this: if((letter & Letters.AB) == Letters.AB) Is there a simpler way to check if any of the flags of a combined flag constant are set than the following? if((letter & Letters.A) == Letters.A || (letter & Letters.B) == Letters.B) Could you for example swap the & with something? Not too stable when it comes to binary stuff like this... yeyeyerman If you want to know if letter has any of the letters in AB you must use the AND & operator. Something like:

overridePendingTransition does not work when FLAG_ACTIVITY_REORDER_TO_FRONT is used

戏子无情 提交于 2019-11-27 04:22:42
I have two activities in the stack, in order to show them I use FLAG_ACTIVITY_REORDER_TO_FRONT. So far so good, the problem comes when I want to bring the activity with an animation using overridePendingTransition. Intent i = new Intent(ActivityA.this, ActivityB.class); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); ActivityA.this.startActivity(i); overridePendingTransition(R.anim.transition_to_right, R.anim.transition_to_left); The transition is not shown, however, if the flag is not added to the intent (removing line 2) then there is no problem. Is it possible to bring an activity to

How to create global variable in Swift?

。_饼干妹妹 提交于 2019-11-27 02:02:51
问题 I am trying to set a global variable. In my case, just a boolean flag that indicates if a view is being presented for the first time: var initialLoadFlag: Bool = true After the view is presented, I want to set this flag to false: var initialLoadFlag: Bool = false And then check for it thenceforth: if initialLoadFlag { showWelcomeMessage() } So, I would like to create initialLoadFlag as a global variable. Where and how? I've tried: In the viewDidLoad area of my view controller In the

PHP function flags, how?

北城余情 提交于 2019-11-27 01:28:14
I'm attempting to create a function with flags as its arguments but the output is always different with what's expected : define("FLAG_A", 1); define("FLAG_B", 4); define("FLAG_C", 7); function test_flags($flags) { if($flags & FLAG_A) echo "A"; if($flags & FLAG_B) echo "B"; if($flags & FLAG_C) echo "C"; } test_flags(FLAG_B | FLAG_C); # Output is always ABC, not BC How can I fix this problem? Ignacio Vazquez-Abrams Flags must be powers of 2 in order to bitwise-or together properly. define("FLAG_A", 0x1); define("FLAG_B", 0x2); define("FLAG_C", 0x4); function test_flags($flags) { if ($flags &

Java flag to enable extended Serialization debugging info

拈花ヽ惹草 提交于 2019-11-27 01:17:52
问题 I am currently struggling with HTTP Session replication on tomcat with complex objects. Some objects implement Serializable but hold non-serializable members. Unfortunately, the stacktraces do not provide much useful info here by default. there is a flag -XX:???? to enable verbose class names in the stacktrace when a NotSerializableException occurrs. this flag would help me a lot finding the source of the error. but i forgot its name What is the name of the flag? 回答1: -Dsun.io.serialization

Opencv的imread用法

泪湿孤枕 提交于 2019-11-27 01:09:25
所有参考来自网上仅仅做学习记录用,具体正确性需要在具体项目各自验证,不涉及具体错误代码处理调试等问题,欢迎发现发现问题~ 参考: 1. https://blog.csdn.net/LiheZhu/article/details/50485317 2. https://mangoroom.cn/opencv/opencv-learning-imread.html 1 . 该函数位于Highgui.h和Loadsave.cpp文件中。 Mat imread( const string& filename, int flags ) { Mat img; imread_( filename, flags, LOAD_MAT, &img ); return img; } 接下来看一下imread_函数中关于flags的部分 int type = decoder->type(); if( flags != -1 ) { if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 ) type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type)); if( (flags & CV_LOAD_IMAGE_COLOR) != 0 || ((flags & CV_LOAD_IMAGE_ANYCOLOR) != 0 && CV_MAT_CN(type) >