Search Results

Search found 1346 results on 54 pages for 'ray casting'.

Page 17/54 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • How to ANSI-C cast from unisigned int * to char *?

    - by user314290
    I want these two print functions to do the same thing: unsigned int Arraye[] = {0xffff,0xefef,65,66,67,68,69,0}; char Arrage[] = {0xffff,0xefef,65,66,67,68,69,0}; printf("%s", (char*)(2+ Arraye)); printf("%s", (char*)(2+ Arrage)); where Array is an unsigned int. Normally, I would change the type but, the problem is that most of the array is numbers, although the particular section should be printed as ASCII.

    Read the article

  • com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to org.codehaus.plexus.util.xml.X

    - by Random
    Afetr using the Model library (see this) for my Maven pom.xml during this weeks I jumped on this error while attempting to write a ConfiguratonContainer into the pom.xml. The javadoc for Model says: public void setConfiguration(Object configuration) Set the configuration as DOM object. Parameters: configuration - So I made some xml with Document (org.w3c.dom.Document) and the xml parser standar javax library. You know the code (it's through all the net) but I paste it here... DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document doc =parser.newDocument(); And then you fill the code with Element declaration,a lot of appendChild and such. And tried to make it work. Doesn't seem to do well. First tried using plugin.setConfiguration(doc); But it didn't work. Then I tried Obejct obj = doc; plugin.setConfiguration(obj); But it didn't work. Then I searched the net for answers, and guess... It didn't work. There are like 0 people using this library (maven.model) in all the net. So here am I again, asking the senseis for help. Where is my error? I have downloaded the source code of the library trying to see where is the error, but it seems to be ok (as should). I add the stackrace for reference java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to org.codehaus.plexus.util.xml.Xpp3Dom at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writePlugin(MavenXpp3Writer.java:1472) at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writeBuild(MavenXpp3Writer.java:326) at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writeModel(MavenXpp3Writer.java:1093) at org.apache.maven.model.io.xpp3.MavenXpp3Writer.write(MavenXpp3Writer.java:102) at com.mapfre.mutua.PDA.model.GeneratePOM.createPOM(GeneratePOM.java:28) at com.mapfre.mutua.PDA.prueba.MavenPOM.generatePOMWAR(MavenPOM.java:681) at com.mapfre.mutua.PDA.prueba.GenerarPOMMapfreAction.execute(GenerarPOMMapfreAction.java:36) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Unknown Source)

    Read the article

  • Converting 'x' value of a CGPoint ivar to NSTimeInterval?

    - by eco_bach
    Hi I have a velocity ivar defined as a CGPoint. I need to somehow extract just the 'x' value of velocity, and then use this to call-send a message to the following method signature -(void) adjustTimer:(NSTimeInterval*)newInterval How do I obtain just the 'x' value of a CGPoint? Do I then need to convert or cast this result before calling my adjustTimer method?

    Read the article

  • Data loss between conversion

    - by Alex Brooks
    Why is it that I loose data between the conversions below even though both types take up the same amount of space? If the conversion was done bitwise, it should be true that x = z unless data is being stripped during the conversion, right? Is there a way to do the two conversions without losing data (i.e. so that x = z)? main.cpp: #include <stdio.h> #include <stdint.h> int main() { double x = 5.5; uint64_t y = static_cast<uint64_t>(x); double z = static_cast<double>(y) // Desire : z = 5.5; printf("Size of double: %lu\nSize of uint64_t: %lu\n", sizeof(double), sizeof(uint64_t)); printf("%f\n%lu\n%f\n", x, y, z); } Results: Size of double: 8 Size of uint64_t: 8 5.500000 5 5.000000

    Read the article

  • Implicit Type Conversions in Reflection

    - by bradhe
    So I've written a quick bit of code to help quickly convert between business objects and view models. Not to pimp my own blog, but you can find the details here if you're interested or need to know. One issue I've run in to is that I have a custom collection type, ProductCollection, and I need to turn that in to a string[] in on my model. Obviously, since there is no default implicit cast, I'm getting an exception in my contract converter. So, I thought I would write the next little bit of code and that should solve the problem: public static implicit operator string[](ProductCollection collection) { var list = new List<string>(); foreach (var product in collection) { if (product.Id == null) { list.Add(null); } else { list.Add(product.Id.ToString()); } } return list.ToArray(); } However, it still fails with the same cast exception. I'm wondering if it has something to do with being in reflection? If so, is there anything that I can do here?? I'm open to architectural solutions, too!

    Read the article

  • C two functions in one with casts

    - by Favolas
    I have two functions that do the exact same thing but in two different types of struct and this two types of struct are very similar. Imagine I have this two structs. typedef struct nodeOne{ Date *date; struct nodeOne *next; struct nodeOne *prev; }NodeOne; typedef struct nodeTwo{ Date *date; struct nodeTwo *next; struct nodeTwo *prev; }NodeTwo; Since my function to destroy each of the list is almost the same (Just the type of the arguments are different) I would like to make just one function to make the two thins. I have this two functions void destroyListOne(NodeOne **head, NodeOne **tail){ NodeOne *aux; while (*head != NULL){ aux = *head; *head = (*head)->next; free(aux); } *tail = NULL; } and this one: void destroyListTwo(NodeTwo **head, NodeTwo **tail){ NodeTwo *aux; while (*head != NULL){ aux = *head; *head = (*head)->next; free(aux); } *tail = NULL; } Since they are very similar I thought making something like this: void destroyList(void **ini, void **end, int listType){ if (listType == 0) { NodeOne *aux; NodeOne head = (NodeOne) ini; NodeOne tail = (NodeOne) ed; } else { NodeTwo *aux; NodeTwo head = (NodeTwo) ini; NodeTwo tail = (NodeTwo) ed; } while (*head != NULL){ aux = *head; *head = (*head)->next; free(aux); } *tail = NULL; } As you may now this is not working but I want to know if this is possible to achieve. I must maintain both of the structs as they are.

    Read the article

  • Need to cast to an object without knowing what type the object is

    - by jle
    I am trying to dynamically load my authentication server type based on a setting. I am hung up on how to cast to a type when I don't know the type. Type t = Type.GetType(WebConfigurationManager.AppSettings.Get("AuthenticationSvcImpl")); IAuthenticationService authCli = Activator.CreateInstance(t); return authCli.AuthenticateUser(login); I know there is Convert.ChangeType(), but that just converts to an object...

    Read the article

  • C++ converting back and forth from derived and base classes

    - by user127817
    I was wondering if there is a way in C++ to accomplish the following: I have a base class called ResultBase and two class that are Derived from it, Variable and Expression. I have a few methods that do work on vector<ResultBase> . I want to be able to pass in vectors of Variable and Expression into these methods. I can achieve this by creating a vector<ResultBase> and using static_cast to fill it with the members from my vector of Variable/Expression. However, once the vector has run through the methods, I want to be able to get it back as the vector of Result/Expression. I'll know for sure which one I want back. static_cast won't work here as there isn't a method to reconstruct a Variable/Expression from a ResultBase, and more importantly I wouldn't have the original properties of the Variables/Expressions The methods modify some of the properties of the ResultBase and I need those changes to be reflected in the original vectors. (i.e. ResultBase has a property called IsLive, and one of the methods will modify this property. I want this IsLive value to be reflected in the derived class used to create the ResultBase Whats the easiest way to accomplish this?

    Read the article

  • boost::shared_ptr<const T> to boost::shared_ptr<T>

    - by Flevine
    I want to cast the const-ness out of a boost::shared_ptr, but I boost::const_pointer_cast is not the answer. boost::const_pointer_cast wants a const boost::shared_ptr, not a boost::shared_ptr. Let's forego the obligitory 'you shouldn't be doing that'. I know... but I need to do it... so what's the best/easiest way to do it? For clarity sake: boost::shared_ptr<const T> orig_ptr( new T() ); boost::shared_ptr<T> new_ptr = magic_incantation(orig_ptr); I need to know the magic_incantation() Thanks!

    Read the article

  • Upcasting without any added data fields.

    - by Benjamin Manns
    In my project I have a generic Packet class. I would like to be able to upcast to other classes (like LoginPacket or MovePacket). The base class contains a command and arguments (greatly simplified): public class Packet { public String Command; public String[] Arguments; } I would like to have be able to convert from Packet to LoginPacket (or any other) based on a check if Packet.Command == "LOGIN". The login packet would not contain any new data members, but only methods for accessing specific arguments. For example: public class LoginPacket : Packet { public String Username { get { return Arguments[0]; } set { Arguments[0] == value; } } public String Password { get { return Arguments[1]; } set { Arguments[1] == value; } } } It would be great if I could run a simple code that would cast from Packet to LoginPacket with something like LoginPacket _Login = (LoginPacket)_Packet;, but that throws a System.InvalidCastException. It seems like this would be an easy task, as no new data is included, but I can't figure out any other way than copying everything from the Packet class to a new LoginPacket class.

    Read the article

  • Generic <T> how cast ?

    - by Kris-I
    Hi, I have a "Product" base class, some other classes "ProductBookDetail","ProductDVDDetail" inherit from this class. I use a ProductService class to make operation on these classes. But, I have to do some check depending of the type (ISBN for Book, languages for DVD). I'd like to know the best way to cast "productDetail" value, I receive in SaveOrupdate. I tried GetType() and cast with (ProductBookDetail)productDetail but that's not work. Thanks, var productDetail = new ProductDetailBook() { .... }; var service = IoC.Resolve<IProductServiceGeneric<ProductDetailBook>>(); service.SaveOrUpdate(productDetail); var productDetail = new ProductDetailDVD() { .... }; var service = IoC.Resolve<IProductServiceGeneric<ProductDetailDVD>>(); service.SaveOrUpdate(productDetail); public class ProductServiceGeneric<T> : IProductServiceGeneric<T> { private readonly ISession _session; private readonly IProductRepoGeneric<T> _repo; public ProductServiceGeneric() { _session = UnitOfWork.CurrentSession; _repo = IoC.Resolve<IProductRepoGeneric<T>>(); } public void SaveOrUpdate(T productDetail) { using (ITransaction tx = _session.BeginTransaction()) { //here i'd like ot know the type and access properties depending of the class _repo.SaveOrUpdate(productDetail); tx.Commit(); } } }

    Read the article

  • Printing the address of a struct object

    - by bdhar
    I have a struct like this typedef struct _somestruct { int a; int b; }SOMESTRUCT,*LPSOMESTRUCT; I am creating an object for the struct and trying to print it's address like this int main() { LPSOMESTRUCT val = (LPSOMESTRUCT)malloc(sizeof(SOMESTRUCT)); printf("0%x\n", val); return 0; } ..and I get this warning warning C4313: 'printf' : '%x' in format string conflicts with argument 1 of type 'LPSOMESTRUCT' So, I tried to cast the address to int like this printf("0%x\n", static_cast<int>(val)); But I get this error: error C2440: 'static_cast' : cannot convert from 'LPSOMESTRUCT' to 'int' What am I missing here? How to avoid this warning? Thanks.

    Read the article

  • java: ClassCastException - [Ljava.lang.Long; cannot be cast to java.lang.Long

    - by ufk
    Hello. well.. I use red5 and setting/getting attributes using the IConnection class but tha's really not relevant. 'L' means long in java. so 0L is 0 type Long instead of just '0' which is 0 type Integer. the following error message: stack trace: java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.lang.Long what's the difference between [Ljava.lang.Long and java.lang.Long ? thanks!

    Read the article

  • how to get child members value from dynamically casted class?

    - by Baka-Maru Lama
    Well I'm tring to get class members values from a dynamically casted class but I'm unable to find its child class members values. Right now I'm getting TotalWeight members property, but I also want to get child member property of AnotherClass like AnotherClass.child. How can I get those members? string ClassName="something"; Type types = Type.GetType(ClassName, false); var d = from source in types.GetMembers().ToList() where source.MemberType == MemberTypes.Property select source; List<MemberInfo> members = d.Where(memberInfo => d.Select(c => c.Name) .ToList() .Contains(memberInfo.Name)) .ToList(); PropertyInfo propertyInfo; object value; foreach (var memberInfo in members) { propertyInfo = typeof(T).GetProperty(memberInfo.Name); if (myobj.GetType().GetProperty(memberInfo.Name) != null) { value = myobj.GetType() .GetProperty(memberInfo.Name) .GetValue(myobj, null); //how to get child members value here? } } //Where class something has member public class something { private decimal _totalWeight; private Anotherclass _another; public decimal TotalWeight { get { return this._totalWeight; } set { this._totalWeight = value; } } public Anotherclass Another { get { return this._another; } set { this._another= value; } } }

    Read the article

  • Converting between unsigned and signed int safely

    - by polemic
    I have an interface between a client and a server where a client sends (1) an unsigned value, and (2) a flag which indicates if value is signed/unsigned. Server would then static cast unsigned value to appropriate type. I later found out that this is implementation defined behavior and I've been reading about it but I couldn't seem to find an appropriate solution that's completely safe? I've read about type punning, pointer conversions, and memcpy. Would simply using a union type work? A UnionType containing signed and unsigned int, along with the signed/unsigned flag. For signed values, client sets the signed part of the union, and server reads the signed part. Same for the unsigned part. Or am I completely misunderstanding something? Side question: how do I know the specific behavior in this case for a specific scenario, e.g. windriver diab on PPC? I'm a bit lost on how to find such documentation.

    Read the article

  • Should I cast variables that use a typdef'd type?

    - by mesorismo
    If I have something like: typedef int MyType; is it good practice to cast the operands of an operation if I do something like this: int x = 5; int y = 6; MyType a = (MyType)(x + y); I know that I don't need to do that but wondering if it's better for intent/documentation/readability concerns.

    Read the article

  • Performance hit from C++ style casts?

    - by Trevor Boyd Smith
    I am new to C++ style casts and I am worried that using C++ style casts will ruin the performance of my application because I have a real-time-critical deadline in my interrupt-service-routine. I heard that some casts will even throw exceptions! I would like to use the C++ style casts because it would make my code more "robust". However, if there is any performance hit then I will probably not use C++ style casts and will instead spend more time testing the code that uses C-style casts. Has anyone done any rigorous testing/profiling to compare the performance of C++ style casts to C style casts? What were your results? What conclusions did you draw?

    Read the article

  • C# Type conversion between two similar Datatable objects

    - by Ali
    I have .NET project with sync framework and two separate Datasets for MS SQL and Compact SQL. in my base class I have a generic DataTable object. in my derived classed I assign Typed DataTable to the generic object based on whether the application is operating online or offline: example: if (online) _dataTable = new MSSQLDataSet.Customer; else _dataTable = new CompactSQLDataSet.Customer; Now every where in my code i have to check and do a cast based on the current network mode like this: public void changeCustomerID(int ID) { if (online) (MSSQLDataSet.CustomerDataTable)_dataTable)[i].CustomerID = value; else (CompactMSSQLDataSet.CustomerDataTable)_dataTable)[i].CustomerID = value; } but I don't think this is very efficient and I believe it can be done in a smarter way to only use one line of code by dynamically getting the Type of _dataTable on the run time. my problem is at the design time, in order to acess datatable porperties such as "CustomerID" it has to be casted to either MSSQLDataSet.CustomerDataTable or CompactMSSQLDataSet.CustomerDataTable. Is there a way to have a function or a operator to convert the _datatable to its runtime type but still be able to use it's design time properties which are the same between the two types? something like: ((aType)_dataTable)[i].CustomerID = value; //or GetRuntimeType(_dataTable)[i].CustomerID = value;

    Read the article

  • Java: Typecasting to Generics

    - by bguiz
    This method that uses method-level generics, that parses the values from a custom POJO, JXlistOfKeyValuePairs (which is exactly that). The only thing is that both the keys and values in JXlistOfKeyValuePairs are Strings. This method wants to taken in, in addition to the JXlistOfKeyValuePairs instance, a Class<T> that defines which data type to convert the values to (assume that only Boolean, Integer and Float are possible). It then outputs a HashMap with the specified type for the values in its entries. This is the code that I have got, and it is obviously broken. private <T extends Object> Map<String, T> fromListOfKeyValuePairs(JXlistOfKeyValuePairs jxval, Class<T> clasz) { Map<String, T> val = new HashMap<String, T>(); List<Entry> jxents = jxval.getEntry(); T value; String str; for (Entry jxent : jxents) { str = jxent.getValue(); value = null; if (clasz.isAssignableFrom(Boolean.class)) { value = (T)(Boolean.parseBoolean(str)); } else if (clasz.isAssignableFrom(Integer.class)) { value = (T)(Integer.parseInt(str)); } else if (clasz.isAssignableFrom(Float.class)) { value = (T)(Float.parseFloat(str)); } else { logger.warn("Unsupported value type encountered in key-value pairs, continuing anyway: " + clasz.getName()); } val.put(jxent.getKey(), value); } return val; } This is the bit that I want to solve: if (clasz.isAssignableFrom(Boolean.class)) { value = (T)(Boolean.parseBoolean(str)); } else if (clasz.isAssignableFrom(Integer.class)) { value = (T)(Integer.parseInt(str)); } I get: Inconvertible types required: T found: Boolean Also, if possible, I would like to be able to do this with more elegant code, avoiding Class#isAssignableFrom. Any suggestions? Sample method invocation: Map<String, Boolean> foo = fromListOfKeyValuePairs(bar, Boolean.class);

    Read the article

  • Converting generic type to it's base and vice-versa

    - by Pajci
    Can someone help me with the conversion I am facing in enclosed code ... I commented the lines of code, where I am having problem. Is this even the right way to achieve this ... what I am trying to do, is forward responses of specified type to provided callback. public class MessageBinder { private class Subscriber<T> : IEquatable<Subscriber<T>> where T : Response { ... } private readonly Dictionary<Type, List<Subscriber<Response>>> bindings; public MessageBinder() { this.bindings = new Dictionary<Type, List<Subscriber<Response>>>(); } public void Bind<TResponse>(short shortAddress, Action<ZigbeeAsyncResponse<TResponse>> callback) where TResponse : Response { List<Subscriber<TResponse>> subscribers = this.GetSubscribers<TResponse>(); if (subscribers != null) { subscribers.Add(new Subscriber<TResponse>(shortAddress, callback)); } else { var subscriber = new Subscriber<TResponse>(shortAddress, callback); // ERROR: cannot convert from 'List<Subscriber<TResponse>>' to 'List<Subscriber<Response>>' ... tried LINQ Cast operator - does not work either this.bindings.Add(typeof(TResponse), new List<Subscriber<TResponse>> { subscriber }); } } public void Forward<TResponse>(TResponse response) where TResponse : Response { var subscribers = this.GetSubscribers<TResponse>(); if (subscribers != null) { Subscriber<TResponse> subscriber; Type responseType = typeof (TResponse); if (responseType.IsSubclassOf(typeof (AFResponse))) { // ERROR: Cannot convert type 'TResponse' to 'AFResponse' ... tried cast to object first, works, but is this the right way? var afResponse = (AFResponse)response; subscriber = subscribers.SingleOrDefault(s => s.ShortAddress == afResponse.ShortAddress); } else { subscriber = subscribers.First(); } if (subscriber != null) { subscriber.Forward(response); } } } private List<Subscriber<TResponse>> GetSubscribers<TResponse>() where TResponse : Response { List<Subscriber<Response>> subscribers; this.bindings.TryGetValue(typeof(TResponse), out subscribers); // ERROR: How can I cast List<Subscriber<Response>> to List<Subscriber<TResponse>>? return subscribers; } } Thank you for any help :)

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >