RTC Forums
November 24, 2024, 04:45:28 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcHttpValues would like a .HasItem[index:string] or .ItemExists[index:string]  (Read 5629 times)
Dany
RTC License++
*****
Posts: 69


« on: September 09, 2015, 03:00:47 PM »

Some requests i have to handle have a really bad way of signalling some details. Like the /omission/ of a value. I can loop through and check ItemName[index:integer] but looking at the code it's not too efficient. It would be logical and convenient IMHO with such a property or function.

Regards,

/Dany
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: September 09, 2015, 03:45:14 PM »

There are already two ways to easily check if a value has been assigned to an attribute in a TRtcHttpValues class.

1. Using the ElementCount[index:string] property, which returns 0 if no values have been assigned.

2. Using the Value[index:string] property, which returns an empty string if no values have been assigned.

Best Regards,
Danijel Tkalcec
Logged
Dany
RTC License++
*****
Posts: 69


« Reply #2 on: September 09, 2015, 04:25:12 PM »

1. Using the ElementCount[index:string] property, which returns 0 if no values have been assigned.

I just realized the minute after i posted  Undecided . It looks efficient enough. Thanks.

2. Using the Value[index:string] property, which returns an empty string if no values have been assigned.

That won't cut it because i need to know if the element was present and if so it could have had a value of an empty string. But #1 is glimmering.

Thanks,

/Dany
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: September 09, 2015, 04:37:17 PM »

TRtcHttpValues class does NOT have a contept of "empty but assigned" values or NULL values. Assigning an empty string to an item stored in the TRtcHttpValues class does nothing, unless a value has previously been stored under that name, in which case the last item will be removed (it will be as if it was never assigned).

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: September 09, 2015, 06:04:19 PM »

Anyway ... I've added the "HasValue" property to the TRtcHttpValues class in RTC SDK v7.00 (just uploaded).

Best Regards,
Danijel Tkalcec
Logged
Dany
RTC License++
*****
Posts: 69


« Reply #5 on: September 10, 2015, 09:53:59 AM »

Not to start a dicussion - i completely understand why and how the concept of null does not exist here - but for others who wonder why i posted; an example is when i get a multipart as the payload. Sometimes a field is present without any data. That will give me an empty string - the same as if the field was not present in the request. In this particular case i needed to find out if the field was present in the multipart (with or without a value different from ''). Granted, that is not a good way to design any request, but that a particular need in the context.

Brilliant, Danijel. Thanks.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.026 seconds with 17 queries.