I have some C++ datatypes for which I would like to improve the debugging experience in my team. I therefore want to create a custom visualizer in the autoexp.dat file. The [AutoExpand] section doesn't seem sufficient, so I started to look at [Visualizer]. I found this website with some explanations, but is there any comprehensive reference/manual/tutorial? I don't get the difference between $c and $e, for example. I already succeeded in displaying some basic information, but I feel like there's so much more to know...
Do you know any good resource?
Thanks!
Appears this is already commented above but someone coming to this question would not necessarily read the comments and so might miss the great tutorial available on the boost site:
https://svn.boost.org/trac/boost/wiki/DebuggerVisualizers
Also
http://mariusbancila.ro/blog/2007/04/06/tweaking-autoexpdat-for-custom-types-in-vs2005/
http://www.idigitalhouse.com/Blog/?p=83
http://www.chromium.org/developers/how-tos/how-to-set-up-visual-studio-debugger-visualizers
http://www.virtualdub.org/blog/pivot/entry.php?id=172
Below is an example of visualizer for boost::tuple. It should be fairly easy to follow:
boost::tuples::tuple<*>{
; Show as (11, 22, 33, ... })
preview (
#(
"("
, $e.head
, ", "
, $e.tail.head
, ", "
, $e.tail.tail.head
, ", "
, $e.tail.tail.tail.head
, ", "
, $e.tail.tail.tail.tail.head
, ", "
, $e.tail.tail.tail.tail.tail.head
, ", "
, $e.tail.tail.tail.tail.tail.tail.head
, ", "
, $e.tail.tail.tail.tail.tail.tail.tail.head
, ", "
, $e.tail.tail.tail.tail.tail.tail.tail.tail.head
, ", "
, $e.tail.tail.tail.tail.tail.tail.tail.tail.tail.head
, ")"
)
)
children (
#(
0: $e.head
, 1: $e.tail.head
, 2: $e.tail.tail.head
, 3: $e.tail.tail.tail.head
, 4: $e.tail.tail.tail.tail.head
, 5: $e.tail.tail.tail.tail.tail.head
, 6: $e.tail.tail.tail.tail.tail.tail.head
, 7: $e.tail.tail.tail.tail.tail.tail.tail.head
, 8: $e.tail.tail.tail.tail.tail.tail.tail.tail.head
, 9: $e.tail.tail.tail.tail.tail.tail.tail.tail.tail.head
)
)
}
Related
I'm trying to find a neat code to standardize names, using google sheet script and regexp.
Each value (all in caps) has a first name composed of 1 or 2 words.
Then comes the second name with just the initial(s). If it is a composed name, there are 2 initials. When there are 2 initials, the formatting varies greatly.
What I want to achieve, using google script : keep the first name full, and standardize the second name as one or two characters followed by a dot.
"LE FARD MA." , "LE FARD M.A." , "LE FARD M-A" , "LE FARD M A." , "LE FARD M. A." , "LE FARD M.-A." , "LE FARD M-A." : should all return "LE FARD MA."
"FARD P". , "FARD P" : should return "FARD P."
I have been trying to learn about regexp for the past few hours, but can't manage to find an answer. Any help much appreciated.
Thanks to the comment of s1c0j1, I managed to get a code working.
function Test() {
var a ="LE FARD M-A.";
var regex = new RegExp(/(?:\s+)(\w?)(?:\.?\s?-?)(\w?)\.?$/);
var res = regex(a);
var haha = a.replace(res[0]," " + res[1] + res[2] + ".");
Logger.log(haha);
}
Maybe not the most elegant way, but problem solved, thanks.
I'm new to SSRS and find the syntax very difficult as well as the awful expression text box that makes it very hard to see where i've made errors.
I want to do IFF (First(Fields!TaxNumber.Value, "InvoiceHeader") = null, then only print IS02Chars.value, else print both IS02Chars and TaxNumber.Value.
=IFF (First(Fields!TaxNumber.Value, "InvoiceHeader") = null ,
": " & First(Fields!ISO2Chars.Value, "InvoiceHeader"),
": " & First(Fields!ISO2Chars.Value, "InvoiceHeader") & First(Fields!TaxNumber.Value, "InvoiceHeader"))
I don't see how my syntax is any different to IIF(Fields!ExitReason.Value = 7, 1, 0)
=IIF(IsNothing(First(Fields!TaxNumber.Value, "InvoiceHeader")), ": "
& First(Fields!ISO2Chars.Value, "InvoiceHeader") , ": " &
First(Fields!ISO2Chars.Value, "InvoiceHeader") &
First(Fields!TaxNumber.Value, "InvoiceHeader" ) )
I've searched many times, and haven't found the answer here or elsewhere. I want to replace each space ' ' in variables containing file names with a '\ '. (A use case could be for shell commands, with the spaces escaped, so each file name doesn't appear as a list of arguments.) I have looked through the StackOverflow question "how to replace single backslash in R", and find that many combinations do work as advertised:
> gsub(" ", "\\\\", "a b")
[1] "a\\b"
> gsub(" ", "\\ ", "a b", fixed = TRUE)
[1] "a\\ b"
but try these with a single-slash version, and R ignores it:
> gsub(" ", "\\ ", "a b")
[1] "a b"
> gsub(" ", "\ ", "a b", fixed = TRUE)
[1] "a b"
For the case going in the opposite direction — removing slashes from a string, it works for two:
> gsub("\\\\", " ", "a\\b")
[1] "a b"
> gsub("\\", " ", "a\\b", fixed = TRUE)
[1] "a b"
However, for single slashes some inner perversity in R prevents me from even attempting to remove them:
> gsub("\\", " ", "a\\b")
Error in gsub("\\", " ", "a\\b") :
invalid regular expression '\', reason 'Trailing backslash'
> gsub("\", " ", "a\b", fixed = TRUE)
Error: unexpected string constant in "gsub("\", " ", ""
The 'invalid regular expression' is telling us something, but I don't see what. (Note too that the perl = True option does not help.)
Even with three back slashes R fails to notice even one:
> gsub(" ", "\\\ ", "a b")
[1] "a b"
The patter extends too! Even multiples of two work:
> gsub(" ", "\\\\\\\\", "a b")
[1] "a\\\\b"
but not odd multiples (should get '\\\ ':
> gsub(" ", "\\\\\\ ", "a b")
[1] "a\\ b"
> gsub(" ", "\\\ ", "a b", fixed = TRUE)
[1] "a\\ b"
(I would expect 3 slashes, not two.)
My two questions are:
How can my goal of replacing a ' ' with a '\ ' be accomplished?
Why did the odd number-slash variants of the replacements fail, while the even number-slash replacements worked?
For shell commands a simple work-around is to quote the file names, but part of my interest is just wanting to understand what is going on with R's regex engine.
Get ready for a face-palm, because this:
> gsub(" ", "\\\ ", "a b", fixed = TRUE)
[1] "a\\ b"
is actually working.
The two backslashes you see are just the R console's way of displaying a single backslash, which is escaped when printed to the screen.
To confirm the replacement with a single backslash is indeed working, try writing the output to a text file and inspect yourself:
f <- file("C:\\output.txt")
writeLines(gsub(" ", "\\", "a b", fixed = TRUE), f)
close(f)
In output.txt you should see the following:
a\b
Very helpful discussion! (I've been Googling the heck out of this for 2 days.)
Another way to see the difference (rather than writing to a file) is to compare the contents of the string using print and cat.
z <- gsub(" ", "\\", "a b", fixed = TRUE)
> print(z)
[1] "a\\ b"
> cat(z)
a\ b
So, by using cat instead of print we can confirm that the gsub line is doing what was intended when we're trying to add single backslashes to a string.
I am trying to clean about 2 million entries in a database consisting of job titles. Many have several abbreviations that I wish to change to a single consistent and more easily searchable option. So far I am simply running through the column with individual mapply(gsub(...) commands. But I have about 80 changes to make this way, so it takes almost 30 minutes to run.
There has got to be a better way. I'm new to string searching, I found the *$ trick, which helped. Is there a way to do more than one search in a single mapply? I imagine that maybe faster?
Any help would be great. Thanks.
Here is some of the code below. Test is a column of 2 million individual job titles.
test <- mapply(gsub, " Admin ", " Administrator ", test)
test <- mapply(gsub, "Admin ", "Administrator ", test)
test <- mapply(gsub, " Admin*$", " Administrator", test)
test <- mapply(gsub, "Acc ", " Accounting ", test)
test <- mapply(gsub, " Admstr ", " Administrator ", test)
test <- mapply(gsub, " Anlyst ", " Analyst ", test)
test <- mapply(gsub, "Anlyst ", "Analyst ", test)
test <- mapply(gsub, " Asst ", " Assistant ", test)
test <- mapply(gsub, "Asst ", "Assistant ", test)
test <- mapply(gsub, " Assoc ", " Associate ", test)
test <- mapply(gsub, "Assoc ", "Associate ", test)
One option would be to use mgsub from library(qdap)
mgsub(patternVec, replaceVec, test)
data
patternVec <- c(" Admin ", "Admin ")
replaceVec <- c(" Administrator ", "Administrator ")
Here is a base R solution which works. You can define a data frame which will contain all patterns and their replacements. Then you use apply() in row mode and call gsub() on your test vector for each pattern/replacement combination. Here is sample code demonstrating this:
df <- data.frame(pattern=c(" Admin ", "Admin "),
replacement=c(" Administrator ", "Administrator "))
test <- c(" Admin ", "Admin ")
apply(df, 1, function(x) {
test <<- gsub(x[1], x[2], test)
})
> test
[1] " Administrator " "Administrator "
I try to find a specific String in a Text File.
The file looks like this:
2, 1, 'Ausbau der techn. Anlagen'
2, 2, 'Extension des installations techniques'
2, 3, 'Estensione delle istallazioni tecniche'
I try to find the text between the '' signs.
//Will be set automaticly after implementation.
int project = 2
int languageInteger = 1
String findings = new File(usedPath)?.eachLine {
it.substring((project+ ", " + languageInteger + ", "))
}
This doesn't work. I've also tried with FindAll Closure or find. But I make some mistakes.
What should I do to find the text?
I found a Solution.
It will not be the best, but it works.
new File(usedPath)?.eachLine {
if(it?.toString()?.startsWith(project+ ", " + languageInteger + ", ")){
findings = it?.toString()?.split(project+ ", " + languageInteger + ", ")?.getAt(1)
}
}