Questions tagged [flags]

Flags are atomic data structures used to identify state in a program.

A flag field is an integer interpreted as a sequence of boolean bits, each called a flag. A single flag has two possible states: 0, representing false or off, and 1, representing true or on.

This tag can be used for problems related to .

Source

Wikipedia

1329 questions
60
votes
6 answers

Enum flags in JavaScript

I need to emulate enum type in Javascript and approach seems pretty straight forward: var MyEnum = {Left = 1; Right = 2; Top = 4; Bottom = 8} Now, in C# I could combine those values like this: MyEnum left_right = MyEnum.Left | MyEnum.Right and…
Andrey
  • 18,432
  • 22
  • 99
  • 163
55
votes
8 answers

Correct way to check for a command line flag in bash

In the middle of a script, I want to check if a given flag was passed on the command line. The following does what I want but seems ugly: if echo $* | grep -e "--flag" -q then echo ">>>> Running with flag" else echo ">>>> Running without…
BCS
  • 67,242
  • 64
  • 175
  • 277
53
votes
11 answers

SameSite cookie in Java application

Do you know any Java cookie implementation which allows to set a custom flag for cookie, like SameSite=strict? It seems that javax.servlet.http.Cookie has a strictly limited set of flags which can be added.
Michal_Szulc
  • 3,335
  • 6
  • 29
  • 51
52
votes
3 answers

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

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…
antonyt
  • 21,626
  • 9
  • 66
  • 68
52
votes
9 answers

Switch on Enum (with Flags attribute) without declaring every possible combination?

how do i switch on an enum which have the flags attribute set (or more precisely is used for bit operations) ? I want to be able to hit all cases in a switch that matches the values declared. The problem is that if i have the following…
MartinF
  • 5,721
  • 5
  • 38
  • 28
51
votes
5 answers

Checking flag bits java

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.
Nagaraju
  • 1,155
  • 2
  • 10
  • 12
51
votes
1 answer

Material design layout_scrollFlags meanings

I find out that we can use cool flags that scroll both toolbar and even content by using layout_scrollFlags. In my case, I have a layout like this:
Mahdi
  • 5,031
  • 5
  • 46
  • 96
44
votes
6 answers

How to disable a log.Logger

I have some heavily instrumented code that makes use of the log package. Now it's come time to turn off the logging, and I can't determine how to turn off the standard logger. Have I missed something? Should I be checking a flag before making log…
Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
42
votes
1 answer

What does regex' flag 'y' do?

MDN says: To perform a "sticky" search, that matches starting at the current position in the target string, use the y flag. I don't quite understand it.
DarkLightA
  • 13,036
  • 16
  • 47
  • 54
42
votes
4 answers

Removing Strikethrough from TextView

I'm using this line below in order to set a strikethrough on my TextView: tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); However later on in the Fragment, if they click the TextView again, I would like the strikethrough to be…
edwoollard
  • 11,875
  • 6
  • 38
  • 69
39
votes
8 answers

Enum.HasFlag, why no Enum.SetFlag?

I have to build an extension method for each flag type I declare, like so: public static EventMessageScope SetFlag(this EventMessageScope flags, EventMessageScope flag, bool value) { if (value) flags |= flag; else flags…
bevacqua
  • 43,414
  • 51
  • 157
  • 277
35
votes
8 answers

Flags in a database rows, best practices

I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice? A good example of this would be the badges on stack overflow, or the…
Evan Teran
  • 80,654
  • 26
  • 169
  • 231
32
votes
2 answers

Python RegExp global flag

Is there a flag or some special key in python to use pattern multiple times. I used to test http://gskinner.com/RegExr/ my RegExp, it worked correctly in it. But when testing in correct enviorment match only returns None. import re pattern =…
Metsavaht
  • 488
  • 1
  • 5
  • 9
31
votes
3 answers

Should command line options in POSIX-style operating systems be underscore style?

Should the name of command line options for a program in a POSIX-style operating system be underscore-style, like --cure_world_hunger or maybe some other style? --cureworldhunger --cure-world-hunger --cureWorldHunger What's most common? What's…
pupeno
  • 256,034
  • 114
  • 324
  • 541
30
votes
8 answers

overridePendingTransition does not work when FLAG_ACTIVITY_REORDER_TO_FRONT is used

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…
Daniel
  • 301
  • 1
  • 3
  • 3
1
2
3
88 89