ios,casting,chromecast,google-cast
This is a piece of the definition given there: ... It provides JavaScript support for parsing manifests and playing HTTP Live Streaming (HLS), MPEG-DASH, and Smooth Streaming content. It also provide support for HLS AES encryption, PlayReady DRM, and Widevine DRM. I hope this is not ambiguous; if your media...
android,class,object,casting,realm
All Realm classes extends RealmObject so you can use generics to accomplish it: public static <T extends RealmObject> void executeInsertInto(final Context context, final T passedObject){ Realm realm = Realm.getInstance(context); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { T itemToWrite = realm.copyToRealm(passedObject); } }); realm.close(); } ...
With vector type detection you might do: #include <iostream> #include <vector> // is_vector // ========= namespace Detail { template<typename T> struct is_vector_test { static constexpr bool value = false; }; template<typename ... Types> struct is_vector_test<std::vector<Types...>> { static constexpr bool value = true; }; } template<typename T> struct is_vector : Detail::is_vector_test<typename...
Use cast_number/*char*/ = (char) help_variable_remove_pv + '0'/*int*/; instead of cast_number/*char*/ = (char) help_variable_remove_pv/*int*/; A character and an integer somewhat are different. This means that '0'(character 0) and integer 0 aren't equal. You'll have to add 48 (ASCII value of '0') to 0 to get the integer value of '0'. See...
For the case of short, the casts are unnecessary because short values are implicitly promoted to int in arithmetic expressions. For the other example, assuming int32 and int64 are what they seem to be, the cast is necessary if int is smaller than 64 bits. Technically, a single cast on...
java,c,casting,network-programming,type-conversion
You have some possible signedness confusion. Consider your byteToInt() function: int byteToInt(char* bytes) { int ch1 = bytes[0]; int ch2 = bytes[1]; int ch3 = bytes[2]; int ch4 = bytes[3]; if ((ch1 | ch2 | ch3 | ch4) < 0) WPRINT_APP_INFO ( ("boh\r\n")); return ((ch1 << 24) + (ch2 <<...
java,inheritance,interface,casting
In a class where we use an instance of A (referenced as A), it is cast to a B Reference so that we can use a Method defined in class B. So I'm assuming you have this scenario public void doStuff(A aType){ ... B bType = (B) aType; ......
android,casting,chromecast,google-cast
To answer your questions: As long as you do not need a custom or styled receiver and are fine with using the Default Receiver, then you do not need to register anything. If you register an app but do not publish that, then it will be visible to only those...
sql-server,date,casting,order,group
If you really need to apply different formatting, you can do it using a derived table: select DATENAME(MM, [date]) + ' ' + CAST(DAY([date]) AS VARCHAR(2)) AS [DD Month], total_quantity from ( SELECT CAST([Datetime] AS DATE) AS [date], SUM(quantity) as total_quantity FROM Invoice_Itemized ii INNER JOIN Invoice_Totals it ON it.Invoice_Number...
From your examples and the error you see, you are attempting to unwrap a value that isn't optional. You don't need to use if let when there is a value. You can force a cast using if let like this: if let myValue:AnyObject = numb.selectedNumber as? AnyObject This will produce...
c++,dictionary,casting,void-pointers,dereference
In addToMap function you can cast the void pointer back to the original type: void addToMap(void *data){ auto pmap = static_cast<map<string, vector<myStruct> >*>(data); pmap->insert(...); } static_cast is also able to perform all conversions allowed implicitly (not only those with pointers to classes), and is also able to perform the opposite...
NO, it is not always true. It is however a bit more complicated than it seems at first glance: In the beginning, let us see what std::string is (21.3/1): The header <string> defines the basic_string class template for manipulating varying-length sequences of char-like objects and four typedefs, string, u16string, u32string,...
java,oop,inheritance,design,casting
At the end of the day, you're branching based on the subtype (concrete classes) since the logic to validate user input is based on those specific details contained in the subclasses. Generics don't really help you much here since generics are based primarily on applying logic that is uniform across...
c#,generics,casting,covariance
The problem is that new DataSeries<SimpleDataPoint> is not IDataSeries<IDataPoint>, because calling IDataSeries<IDataPoint>.Value = new AnotherDataPoint() and IDataPoint value = IDataSeries<IDataPointBase>.Value can fail. That is, runtime can't guarantee that what you're doing is type-safe, so it throws an exception to tell you that. Runtime can only guarantee one of these operations...
java,list,generics,multidimensional-array,casting
Am I worrying too much because all this stuff will be erased at runtime anyway? In a sense, yes - the method you've posted should work just as well with empty lists as with populated lists. Which isn't to say it will work well, but it won't have any...
If you are using SQL Server 2012, you can use DATEFROMPARTS function to form a date, DateDiff to find the difference between two dates and finally cast(do you really have to??) your results to integer CAST(DATEDIFF(day, DATEFROMPARTS(2012,10,1 ), DateHired)/365 AS INTEGER) ...
You are trying to assign Label to int, Label lbl = grdContact.Rows[e.RowIndex].FindControl("lblId_Row") as Label; if(lbl != null) { int id_row = int.Parse(lbl.Text); } ...
You may have to define your own function.Here is an example I just tested, hope it is helpful to you(BTW: It is not advisable to implement such kind of functions in mysql. Maybe it is better to let the application servers to compute it instead of mysql :)). DELIMITER $$...
Your type CT32 is a Discriminated union with one case identifier CT32 of float. It's not an alias to float type so you couldn't just cast it to float. To extract the value from it you can use pattern matching (this is the easiest way). type CT32 = CT32 of...
It's telling you that it is expecting to find a method that takes an int parameter, but you have declared your method to take a long. While you can pass an int to a method that's expecting a long, the method signature is different, and so the expected signature is...
ios,arrays,swift,casting,type-conversion
Airspeed Velocity gave you the answer: var arr: [Int] = [1,2,3,4,5] var stringArray = arr.map { String$($0) } Or if you want your stringArray to be of type [String?] var stringArray = arr.map { Optional(String$($0)) } This form of the map statement is a method on the Array type. It...
char yourChar = 'a'; unsigned char yourUChar = static_cast<unsigned char>(yourChar); int yourInt = 1; unsigned int yourUInt = static_cast<unsigned int>(yourInt); A vector is just multiple ints, you'd cast each member in the vector. Same goes with a matrix. If you cast a signed value that has a negative value, to...
The compiler sees the T2 and T identifiers and helpfully informs you that those types seem unrelated. That's absolutely correct, as they have no relation: there are no generic constraints that would assert any relations between them (I'm not saying that would be useful here though :) ). Whether this...
sql,postgresql,casting,plpgsql
This can be done by trapping an exception in a plpgsql function. create or replace function my_to_timestamp(arg text) returns timestamp language plpgsql as $$ begin begin return arg::timestamp; exception when others then return null; end; end $$; select id, c1, my_to_timestamp(c1) as c2 from a; Trying to define a generic...
c++,casting,parameter-passing,pass-by-reference
In the first example, you're actually passing the pointer variable b. So it works. In the second example, the first reinterpret_cast returns a pointer (by value), which doesn't match the reference the function should get, while the second returns said reference. As an example to show you how references work,...
arrays,swift,casting,nsdate,nsdictionary
I dont know how you set up things before this little snippet in you question but this is how I did: var arr:[[String:AnyObject]] = [["id":1, "planning_id":2, "started_on":"2015-05-13"], ["id":1, "planning_id":2, "started_on":"2015-05-14"], ["id":1, "planning_id":2, "started_on":"2015-05-10"]] for (i, dict) in enumerate(arr) { let dateString = dict["started_on"] as! String let formatter = NSDateFormatter() formatter.dateFormat...
I think using intptr_t is the correct intermediate here, since it's guaranteed to be large enough to contain the integral value of the void*, and once I have an integer value I can then truncate it without causing the compiler to complain. Yes, for the reason you mentioned that's...
What you are failing to see is that a+b is a run-time operation whereas byte b = (int)8; is a compile-time operation. SO, during compile-time, the compiler knows that the constant 8 can be fit in a byte. So, the explicit conversion to (int) is ignored. The byte code will...
They are string values, you can't cast string to int. You need to Convert/Parse it like: parameters[parameters.FindIndex(x => x.Name == "IDs")].Values .Cast<String>() //So that LINQ could be applied .Select(int.Parse) .ToList() You need .Cast<String>() so that you can apply LINQ on the StringCollection. ...
c#,casting,subclass,base-class
the baseClass1 is an instance of Base, even though I used the Sub() constructor. That is totally not true. baseClass1 is an instance of Sub assigned to variable typed as Base. That's why you can cast it back to Sub....
If I'm understanding your question, before you perform any calculations you need to AND (&) your bytes against 255, so you'll be dealing with values from 0 to 255 instead of -128 to 127. When you assign a value higher than 127 to a byte it overflows, so 128 as...
In my opinion, this is a "pointer to pointer to int". No. Its pointer to an array of 10 ints. Then I would assume that &array is of type (int (*)[10]) Yes. Your assumption is correct. &array is the address of array array and is of type int (*)[10]....
(*var) means that var is a pointer variable, and it will indirect through the pointer to access the object it points to. Adding [n] means that it points to an array, and this will then access the nth element of the array. Don't confuse (*var)[n] with *var[n]. The latter is...
casting,compiler-errors,fortran
The value 1_Real32 is an int-literal-constant (R407, Fortran2008 4.4.2.2 5). To get a real value instead you need to change it to 1._Real32. The presence of the decimal makes it a real-literal-constant (R413, Fortran2008 4.4.2.3 6). Remember that Real32 in your code is just a number, e.g. 4 and it...
c++,casting,type-safety,reinterpret-cast
No it is not safe: the program behaviour is undefined. This is because the pointer types are unrelated....
C c = (C)i; Since i can hold instance of type C there is no problem with allowing by compiler casting I to C type reference (if casting will succeed at runtime we will be sure that all methods from C reference will be supported by instance which will...
Cast the variables to a long int or long long int type giving at the same time the range of unsigned int (0..2^32-1) and sign.
Use following code to print 2D array: String deepToString(Object[] a) System.out.println(Arrays.deepToString(your2DArray)); Use below to print 1D array System.out.println(Arrays.toString(your1DArray)); ...
ios,objective-c,osx,properties,casting
((Company*)myObject.companies[0]).myId Should do the trick...
If you are using the version of Code::Blocks with mingw, see this answer: Conversion specifier of long double in C mingw ... printf does not support the 'long double' type. Some more supporting documentation for it. http://bytes.com/topic/c/answers/135253-printing-long-double-type-via-printf-mingw-g-3-2-3-a If you went straight from float to long double, you may try just...
static_cast is not a function, it's a keyword, so the comma in a, b is not an argument separator; it is the comma operator. It evaluates a but throws away the result. The expression evaluates to b.
There are a lot of questions on dynamic_cast here on SO. I read only a few and also don't use that method often in my own code, so my answer reflects my opinion on this subject rather than my experience. Watch out. (1.) Why is casting up/down considered bad design,...
Change to: class MyClass { public: static const int MAJOR = 3; static const int MINOR = 3; static const int REV = 0; }; If these versions are constant. Otherwise as: class MyClass { public: static int MAJOR; static int MINOR; static int REV; }; Then somewhere in a...
Basically your scenario is that you want to type cast with the type stored in a variable. You can only do that at runtime like this : myclass s=new myclass(); s.value = "10"; s.type = typeof(int); var val = Convert.ChangeType(s.value, s.type); but since the conversion is done at runtime, you...
c,pointers,casting,compiler-errors,void-pointers
This line: ptr = (struct sockaddr_in *) res->ai_addr; does not do what you think it does; it doesn't automagically make ptr be of type struct sockaddr_in *, so you're still trying to dereference a void pointer. What you need to do is printf("Port number: %u\n", ntohs(((struct sockaddr_in *) res->ai_addr)->sin_port)); ...
You could try union - as long as you make sure the types are identical in memory sizes: union convertor { int asInt; float asFloat; }; Then you can assign your int to asFloat (or the other way around if you want to). I use it a lot when I...
As far as I can tell the issue is that QPointF provides a constructor which takes a QPoint. When you do a static_cast the compiler tries to call QPointF(MyPoint&) and it sees two ways to create a QPointF from MyPoint: Use the constructor taking a QPoint, by converting MyPoint to...
As arkascha said, htmlspecialchars and real_escape_string both return strings, it's kind of implied in the function of both. If you want ints, floats ect ect to return with the original datatype you'll just need to not perform the cleaning on them. It doesn't really make sense to try to escape...
ios,json,swift,casting,afnetworking
By default, AFHTTPRequestOperationManager sets responseSerializer to an AFJSONResponseSerializer instance, so responseObject already is your parsed JSON set as Dictionary. Here is the code (refactored to remove some redundancy in casting and typing): func jsonLoaded(responseObject: AnyObject) { if let data = responseObject as? NSDictionary { let count = data.count print(count) for...
The error is cList is a list, so you can cast it directly to character the component you get with cList[i], because this is also a list! If you have myList = list(a=1, b=2, c=3), myList[1] and myList[1:2] are lists (try class(myList[1]) and class(myList[1:2]) to check). On the other hand,...
The difference is You are dereferencing the int and casting it to float in printf("(float)* : %f\n", (float)*iptr); which is fine. You are casting the int pointer to a float pointer, and printing the float pointer with the "%f" specifier is undefined behavior, the correct specifier for printing pointers is...
You can try this way : for $x in //onboard/*[*] return sum($x/*) That reads : for $x as each child of <onboard> having at least one child element, return sum of all children element of $x. UPDATE : Turned out that the problem was due to empty element(s) passed to...
Your sample code has either one or several problems with it if you are attempting to print out true. How many depends on how you're trying to do that. My first two points apply if you are comparing text to other text. If you're trying to convert text to a...
The return type of Read() is probably something like IEnumerable<Entity> or List<Entity>. That's why you can't cast them to a single Category. If you need a one line solution for this, you could try var categories = categoryDao.Read().OfType<Category>(); or (thanks @Binkan Salaryman) var categories = categoryDao.Read().Cast<Category>(); (the former will return...
vb.net,combobox,casting,datatable
I would use TryCast to get the job done. Dim dt As DataTable = TryCast(combobox1.DataSource, DataTable) If dt Is Nothing Then ' It didn't work because it's not a datatable ' Editors: I specifically did not reduce this expression ' to emphasize the need to check for 'Nothing' ' and...
You could use Convert's ChangeType-method: public Y get<Y>() { return (Y)Convert.ChangeType(data[pos], typeof(Y)); } It might also be a good idea to add some generic constraints to your class and method to ensure only primitives can be passed: class it<X> where X : struct public Y get<Y>() where Y : struct...
postgresql,casting,postgresql-9.4
It is typed constant - see http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html section 4.1.2.7. Constants of Other Types. A constant of an arbitrary type can be entered using any one of the following notations: type 'string' 'string'::type CAST ( 'string' AS type ) ...
You can cast Int to NSNumber in this way let a:Int? = 10 let b = a! as NSNumber So,in your code,just try self.tv_salaryNumber.text = (earningsSoFar! as NSNumber).stringValue Also,as zeneak said,you can make it easier in his way...
According to the Java Language Specification, Section 3.10.1, the only integer type suffix for integer literals is L (or lower case l). An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (§4.2.1). The suffix...
python,unicode,casting,web-crawler,unicode-string
Use a RegEx to extract the price from your Unicode string: import re def reducePrice(price): match = re.search(r'\d+', u' $500 ') price = match.group() # returns u"500" price = str(price) # convert "500" in unicode to single-byte characters. return price Even though this function converts Unicode to a "regular" string...
Though B has all the methods and property dose A have, you can not cast object of B to a reference of A. That means - A a = (A) new B(); is invalid unless B extends A. And here A is a final class so you can not extends...
The second method that you show is not casting; it's simply calling the toString() method on an object, which is not different than any other method call: String str2 = o.toString(); The effect of the first and third methods is essentially the same. I would prefer using the first method....
java,inheritance,casting,subclass,superclass
A superclass cannot know subclasses methods. Think about it this way: You have a superclass Pet You have two subclasses of Pet, namely: Cat, Dog Both subclasses would share equal traits, such as speak The Pet superclass is aware of these, as all Pets can speak (even if it doesn't...
The cast does not apply to the entire expression 123/33. You're casting the value 123 to a float, which causes any further operations to use floating-point math.
java,serialization,arraylist,casting,deserialization
It tells your that the compiler is unable to guarantee you that the cast would be successful in runtime - it may produce ClassCastException. Usually you are able to check type previously with instanceof to prevent this warning, e.g.: if (x instanceof ArrayList) { ArrayList y = (ArrayList) x; //...
This macro is designed to validate a certain real parameter passes a certain validation rule(s). The logic part of the macro is composed of 2 parts: Validate that param is a real parameter, with a valid name. This is done by using the static_cast, and if an illegal name is...
c#,json,serialization,casting,json.net
Because the type of deserializedData["key"] is Int64 (you'll see when you debug). You can't cast Int64 to int (Int32) . what you can do: int value = System.Convert.ToInt32(deserializedData["key"]); ...
You can use parse() and eval(): foo <- eval(parse(text = function_code)) > foo function(x) { as.dist(1-cor(t(x))) } Just wrap that in a function: parseEval <- function(text) { eval(parse(text = text)) } If you need an actual something() rather than a direct call. Here's an example: set.seed(1) x <- matrix(runif(20), ncol...
c#,generics,casting,extension-methods
Change from IEnumerable<T> to the non generic IEnumerable (which the generic version inherits from anyway). public static IEnumerable<T> log_elements<T>(this IEnumerable<T> collection, bool recursive = true) { logElementsInternal(collection, recursive); return collection; } private static void logElementsInternal(IEnumerable collection, bool recursive) { Form1.log("["); foreach (var i in collection) if(recursive && i is IEnumerable)...
The error is simply occurring as your destination column can only have one data type. The first part of your CASE statement is effictively setting the column type to expect an integer, so when you hit the ELSE section and try to insert Not Same, you're getting the error. Sample:...
c,casting,floating-point,printf
7 / 3 without a cast is integer division, resulting in the integer 2, since any remainder is discarded, so it is equivalent of calling printf("%0.2f\n", 2); Now, why does that print 0 instead of 2? Well, you told it it is a float in the format string ("%0.2f"). So...
Yes, you're correct but I guess, this question needs a little more elaborated answer for why we are doing this. To start with, let's see what is done by the unary * operator. It dereferences it's operand based on the type of the operand. To elaborate in very simple terms,...
Casting is a way for a programmer to tell the computer that, even though the computer thinks something is one type, we want to treat it as another type. But here the cast is of no use as here a is an integer and thus address of a will need...
When you assign to an owned variable Vala has to copy the value (in this case the types aren't reference counted, so copying is the only way). The problem here is with the copying, not the casting. Assign it to an unowned variable: unowned GI.CallableInfo myCallableInfo = (GI.CallableInfo) myBaseInfo; ...
I think the problem is that you are passing an address that is on the stack, the int address cast as a char address. But that int location goes out of scope right after the send. One fix, if I'm right about that, would be to make the int location...
Is there a way to do so? Dim valueNothing = ConvertHelper.SafeChangeType(Of Boolean)(Nothing) Dim valueTrue = ConvertHelper.SafeChangeType(Of Boolean)(True) Dim valueFalse = ConvertHelper.SafeChangeType(Of Boolean)(False) ' ... Class ConvertHelper Shared Function SafeChangeType(Of T As Structure)(ByVal value As Object) As T? Return If(value Is Nothing, Nothing, DirectCast(Convert.ChangeType(value, GetType(T)), T?)) End Function End Class...
Your dynamic_cast fails in both cases, as you cannot safely downcast a Base to a Derived (your initial object is a Base, new Base). You should test the result of the dynamic cast if(!d1) // d1 is nullptr here std::cout << "Failed dynamic_cast"; Delete-ing a nullptr is a no-op, so...
There's no difference in the resulting value, just: (float) is a language feature and very quick floatval() incurs the overhead of a function call (minimal, but nonetheless...) floatval() as a function can be used in ways that (float) cannot, e.g. array_map('floatval', $foo) The last point is, I believe, the main...
SELECT TIMESTAMP_FORMAT("DATEFIELD",'YYYYMMDD') as "MyDate"
t= *(short *)(a+1); You cast the pointer to the first element to a pointer-to-short, and then dereference it. Note that this is not very portable, and can go wrong if the machine is big endian or aligns data somehow. A better way would be: t = (a[2] << CHAR_BIT) |...
java,casting,method-overloading
You are mixing up memory space of variables and their type. Calling the method m(...) will first of all check the type of the paramether variable. Here it is an int so it will chose the according overloaded method, no matter the size of the int in memory. Although I...
Casting doesn't affect the variable and the corresponding memory. It's just and indication for the compiler how to interpret the bits the reside at the given location. In Marcus'es example: int i = 12; double d = (double)i; d is a new variable in a completely new location. The original...
Bit-wise arithmetic is well defined and perhaps more efficient. For this example: return seed ^ (seed >> 32); ...
ios,objective-c,memory,types,casting
Your problem is that you're using a constant string. This is put straight into the programs memory so the reference is unexpectedly remaining valid despite the fact that it shouldn't. Use something less constant than a constant string and your program will brake like you think.
You can't add numbers to characters in FreeMarker out-of-the-box. The closest thing is num?lower_abc (and n?upper_abc), which converts 1 to 'a', 2 to 'b', and so on. If you can't solve the task with that, and you can't add Java classes either, then this is going to be problem... Also,...
c#,inheritance,interface,casting,task-parallel-library
That is because this statement Task.Factory.StartNew(() => new Foo()); returns an instance of type Task<Foo>. And given that the Task<> class is a concrete class, it cannot be covariant, unless it were implementing a covariant interface (i.e. ITask<out T>). Note that there is a uservoice topic to do just that:...
c#,dictionary,casting,ienumerable,deferred-execution
ToDictionary returns what you need. Just return that instead of returning query. return query.GroupBy(word => word) .ToDictionary(g => g.Key, g => g.Count()); ...
You're trying to cast your object to Class but I bet you intended to cast the object to the type that c represents. If so you should use Class.cast. For example: Class<String> c = String.class; String s = c.cast(o); If you want to return null in case it's the wrong...
sql,sql-server,stored-procedures,casting
Yes, you can pass sql_variants as parameters to sp_executesql, but you'll need to continue down the dynamic SQL route with the "Cast to" type, and use the name of the Type that you've determined for the column to be used in a CAST. Take this for example: CREATE TABLE Foo...
java,spring,spring-mvc,generics,casting
You should probably use a common interface shared by both classes. Declaring an interface like, for instance: public interface INotes{ } public class GroupNotes implements INotes{...} public class Notes implements INotes{...} Your code would become: @PreAuthorize("hasRole('ROLE_USER')") @RequestMapping(value = "/findnotebydays/{days}/{canvasid}/{mode}") public @ResponseBody List<INotes> findNotesByDays(@PathVariable("days")int days, @PathVariable("canvasid")int canvasid, @PathVariable("mode")boolean mode ){ if(!mode){...
The reason (char)((unsigned char)~0 >> 1) is 127 is obvious - You have 0xFFFFFFFF, cast it to unsigned char, you get 0xFF, shift by one and you have 0x7F or 127. The weird thing is why the first one is wrong: You cast a zero into unsigned char. Then you...
You are close and in fact you can write to a dictionary using +=, the problem is your cast. For example we can do: var dict = ["number" : 2] dict["number"]! += 10 and now dict["number"] returns 12. Now this is creating a new value (12) and replacing it into...
java,class,oop,methods,casting
When using inheritance within classes, overriding a method will ALWAYS call the child method regardless of casting. You can never change the type of an object, so a RockMusician - although it is an extension of Musician - is still a RockMusician and will be called by its type, not...