Hi Richard,
I guess you didn't spot this bit on that page:
JsonVariant
JsonVariant::operator|
Links to
https://arduinojson.org/v6/api/jsonvariant/or/
It's using operator overloading on that class to change what a normal "|" (bitwise or) would usually do.
Regards,
Paul
On Wed, 19 Jan 2022 16:37:01 +0000
Graham Driver <
graham...@hotmail.com> wrote:
> Google says that | can be used as a non-short-circuiting version of ||. I understand the concept but have no idea about the implications.
>
> In any event I guess the chap is looking for something being false, null, empty or zero.
>
> ________________________________
> From:
sheffield-har...@googlegroups.com <
sheffield-har...@googlegroups.com> on behalf of Richard Langner <
richard...@gmail.com>
> Sent: 19 January 2022 15:57
> To:
sheffield-har...@googlegroups.com <
sheffield-har...@googlegroups.com>
> Subject: Re: [SHH:17341] C++ OR used on strings
>
> As I understand it, single pipe is bitwise OR, double pipe is logical OR.
> ________________________________
>
> On 19/01/2022 15:53, nop head wrote:
> The port is an int, not a string, so it should definitely do a bitwise OR, which is a bug as far as I can see. Perhaps they should be both ||.
>
> ________________________________
> On Wed, 19 Jan 2022 at 14:20, Richard Langner <
richard...@gmail.com<mailto:
richard...@gmail.com>> wrote:
> On this page<
https://arduinojson.org/v6/example/config/> there is an OR operator which is a single pipe character (|)
>
>
> // Copy values from the JsonDocument to the Config
> config.port = doc["port"] | 2731;
> strlcpy(config.hostname, // <- destination
> doc["hostname"] | "
example.com<
http://example.com>", // <- source
> sizeof(config.hostname)); // <- destination's capacity
>
>
> If the first parameter can't be found it returns the second on these lines
>
> config.port = doc["port"] | 2731;
>
> and
>
> doc["hostname"] | "
example.com<
http://example.com>"
>
>
> I've not seen this before and wonder why it's not doing a bitwise OR as I would expect from the single pipe (|) character.
>
> Can anyone point me to guidance on this?
>
> Richard
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Sheffield Hackspace" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sheffield-hardware-...@googlegroups.com<mailto:
sheffield-hardware-...@googlegroups.com>.
> To view this discussion on the web, visit
https://groups.google.com/d/msgid/sheffield-hardware-hackers/4fb3c542-d6b5-bb54-8156-73edf0097b69%40gmail.com<
https://groups.google.com/d/msgid/sheffield-hardware-hackers/4fb3c542-d6b5-bb54-8156-73edf0097b69%40gmail.com?utm_medium=email&utm_source=footer>.
> --
> You received this message because you are subscribed to the Google Groups "Sheffield Hackspace" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sheffield-hardware-...@googlegroups.com<mailto:
sheffield-hardware-...@googlegroups.com>.
> To view this discussion on the web, visit
https://groups.google.com/d/msgid/sheffield-hardware-hackers/CAEEmnrPzcd6T7NAmaGpeU72GDhbS5QKfXS-aOXhVG_-%2B4f1k%2BA%40mail.gmail.com<
https://groups.google.com/d/msgid/sheffield-hardware-hackers/CAEEmnrPzcd6T7NAmaGpeU72GDhbS5QKfXS-aOXhVG_-%2B4f1k%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Sheffield Hackspace" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sheffield-hardware-...@googlegroups.com<mailto:
sheffield-hardware-...@googlegroups.com>.
> To view this discussion on the web, visit
https://groups.google.com/d/msgid/sheffield-hardware-hackers/4dd3c272-5212-9bd7-1409-9a149c60b06f%40gmail.com<
https://groups.google.com/d/msgid/sheffield-hardware-hackers/4dd3c272-5212-9bd7-1409-9a149c60b06f%40gmail.com?utm_medium=email&utm_source=footer>.
>