Hi, I need to convert an integer into a string. I would normally do that in C++ by using the StringStream class, but the LLVM coding standards discourage using that class. The same coding standards suggest to use llvm:StringStream instead, but I cannot find that class anywhere; furthermore, the header file where it was supposed to be (according to the coding standards) doesn't even exist. Is there any LLVM-native way to do that? What I want to do is to replicate a function several times and append a sequence number to each replica's name. Thanks ahead, Pablo
On Oct 12, 2011, at 8:18 AM, Pablo Barrio wrote:> Hi, > > I need to convert an integer into a string. I would normally do that in C++ by using the StringStream class, but the LLVM coding standards discourage using that class. The same coding standards suggest to use llvm:StringStream instead, but I cannot find that class anywhere; furthermore, the header file where it was supposed to be (according to the coding standards) doesn't even exist. > > Is there any LLVM-native way to do that? > > What I want to do is to replicate a function several times and append a sequence number to each replica's name. > > Thanks ahead, > PabloThis doesn't really answer your question. Instead I offer information to the llvm community: C++ 11 offers these new functions in <string>: string to_string(int val); string to_string(unsigned val); string to_string(long val); string to_string(unsigned long val); string to_string(long long val); string to_string(unsigned long long val); string to_string(float val); string to_string(double val); string to_string(long double val); The only place I know of in current use where they are not implemented is Apple's v4.2 libstdc++. I believe they've been in gcc and VC++ for several years. They are also in libc++. Howard
Hi Pablo, Can you provide a link to the document containing a reference to llvm::StringStream? I've looked in both the llvm coding standards, and llvm programming manual for versions: ToT (3.0), 2.9 (which seems to be the same as ToT), and 2.8. Obviously my search is missing something. Thanks in advance Garrison On Oct 12, 2011, at 8:18, Pablo Barrio wrote:> Hi, > > I need to convert an integer into a string. I would normally do that in C++ by using the StringStream class, but the LLVM coding standards discourage using that class. The same coding standards suggest to use llvm:StringStream instead, but I cannot find that class anywhere; furthermore, the header file where it was supposed to be (according to the coding standards) doesn't even exist. > > Is there any LLVM-native way to do that? > > What I want to do is to replicate a function several times and append a sequence number to each replica's name. > > Thanks ahead, > Pablo > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Try utostr_32/utostr/itostr defined in the llvm/ADT/StringExtras.h. Zonr On Wed, Oct 12, 2011 at 8:18 PM, Pablo Barrio <p.barrio.lopez at gmail.com>wrote:> Hi, > > I need to convert an integer into a string. I would normally do that in C++ > by using the StringStream class, but the LLVM coding standards discourage > using that class. The same coding standards suggest to use llvm:StringStream > instead, but I cannot find that class anywhere; furthermore, the header file > where it was supposed to be (according to the coding standards) doesn't even > exist. > > Is there any LLVM-native way to do that? > > What I want to do is to replicate a function several times and append a > sequence number to each replica's name. > > Thanks ahead, > Pablo > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111012/a46963f4/attachment.html>
On 12.10.2011, at 16:54, Howard Hinnant wrote:> > string to_string(int val); > string to_string(unsigned val); > string to_string(long val); > string to_string(unsigned long val); > string to_string(long long val); > string to_string(unsigned long long val); > string to_string(float val); > string to_string(double val); > string to_string(long double val); > > The only place I know of in current use where they are not implemented is Apple's v4.2 libstdc++. I believe they've been in gcc and VC++ for several years. They are also in libc++.VC++ only has had them since VS2010, and they're quite broken: too few overloads lead to ambiguity errors when doing very reasonable things. Sebastian
http://llvm.org/releases/2.0/docs/CodingStandards.html I just realized that the target version is LLVM 2.0, so most likely the llvm::StringStream is deprecated by now. Thanks for your response! On 12/10/2011, at 17:10, Garrison Venn wrote:> Hi Pablo, > > Can you provide a link to the document containing a reference to > llvm::StringStream? I've looked in both the llvm coding standards, > and llvm programming manual for versions: ToT (3.0), 2.9 (which > seems to be the same as ToT), and 2.8. Obviously my search is > missing something. > > Thanks in advance > > Garrison > > On Oct 12, 2011, at 8:18, Pablo Barrio wrote: > >> Hi, >> >> I need to convert an integer into a string. I would normally do that in C++ by using the StringStream class, but the LLVM coding standards discourage using that class. The same coding standards suggest to use llvm:StringStream instead, but I cannot find that class anywhere; furthermore, the header file where it was supposed to be (according to the coding standards) doesn't even exist. >> >> Is there any LLVM-native way to do that? >> >> What I want to do is to replicate a function several times and append a sequence number to each replica's name. >> >> Thanks ahead, >> Pablo >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111013/c4aecd46/attachment.html>
https://bitbucket.org/carli/gwscript/src/tip/libs/strings.ll where string is defined with %.string = type {i32, i32, i32, [0 x i8]} (reference counter, length, max-length of the buffer, content) you can modify and adapt the sources as you want. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111013/293965c9/attachment.html>