Hi,
After highlighting text, I would like to obtain the paragraph in which the selected text resides.
var select = window._content.document.getSelection();
Any pointers please?
I have two classes that I'm using to represent some hardware: A Button and an InputPin class which represent a button that will change the value of an IC's input pin when it's pressed down. A simple example of them is:
template <int pinNumber> class InputPin
{
static bool IsHigh()
{
return ( (*portAddress) & (1<<pinNumber) );
}
};
template <typename InputPin> class Button
{
static bool IsPressed()
{
return !InputPin::IsHigh();
}
};
This works beautifully and by using class templates, the condition below will compile as tightly as if I'd handwritten it in assembly (a single instruction).
Button < InputPin<1> > powerButton;
if (powerButton.IsPressed())
........;
However, I am extending it to deal with interrupts and have got a problem with circular references.
Compared to the original InputPin, a new InputPinIRQ class has an extra static member function that will be called automatically by the hardware when the pin value changes. I'd like it to be able to notify the Button class of this, so that the Button class can then notify the main application that it has been pressed/released. I am currently doing this with function pointers to callbacks. In order for the callback code to be inlined by the compiler, I need to pass the function pointers as template parameters. So now, both of the new classes have an extra template parameter that is a pointer to a callback function. Unfortunately this gives me a circular reference because to instantiate a ButtonIRQ class I now have to do something like this:
ButtonIRQ< InputPinIRQ< A1, ButtonIRQ<....>::OnPinChange, OnButtonChange > pB;
where the <...... represents the circular reference.
Does anyone know how I can avoid this circular reference? I am new to templates, so might be missing something really simple.
It's important that the compiler knows exactly what code will be run when the interrupt occurs as it then does some very useful optimisation - it is able to inline the callback function and literally inserts the callback function's code at the exact address that is called on a h/w interrupt.
I want to make a home directory for each user of every group in AD using a batch script.
the users personal directories (my documents, ...) should be stored in there as well.
the path should be as following:
\Fileserver{group name}{user name}
can someone give me some pointers on how to achieve this?
This question was inspired by What features would you like to see added to C++? (also see What features do you miss in C++?).
C++ is a great general-purpose language, but perhaps too general and feature-rich: multiple inheritance, operator overloading, manual memory management, templates, smart pointers, virtual destructors, legacy frameworks (think MFC), and I could go on.
Is there any one feature or aspect of C++ that you would like removed to make our lives easier as C++ developers?
One feature per answer, please.
I Have a list with "a" and "b" and the "b"'s are somewhat of a path and "a"'s are walls. Im writing a program to make a graph of all the possible moves. I got the code running to check the first "b" for possible moves, but i have NO Idea how im going to find all "b"'s , even less check them all without repeating.
Major issue im having is getting the tuple coordinates of the "b"'s out of the list.
Any pointers/tips?
I am reading a book which says (if I am not getting it wrong) wrapping some code with @autoreleasepool statement enables the ARC. First of all is this the case ?
My second concern is when I am doing some iOS example programs, although I enable ARC when creating a new project, I never see this directive being used anywhere (in the automatically generated code). Does this mean that ARC is not being used ? Any ideas/pointers is appreciated.
Are there any best practices when it comes to styling Flex applications ? I would like to give the html page designer as much flexibility as possible.
Any tips, pointers?
I need to get the fillcolor from a legendItem, howerver doing
lItem.getStyle("fill")
returns a different color than the actual legendItem marker color. Any pointers on what am I doing wrong here?
I'm conflicted between a "read once, use memory+pointers to files" and a "read when necessary" approach. The latter is of course much easier (no additional classes needed to store the whole dir structure), but IMO it is slower?
A little clarification: I'm writing a simple build system, that read a project file, checks if all files are present, and runs some compile steps. The file tree is static, so the first option doesn't need to be very dynamic and only needs to be built once every time the program is run. Thanks
I am trying to create a application with a tab bar and a common WebView.
The different tabs shows/hides different divs in the WebView but maintain the state otherwise, so I need to share the web view between the tabs.
I am trying to use a nib, but I think that might not be the right solution here.
Any pointers for doing this correctly?
Is it possible to store a type name as a C++ variable? For example, like this:
type my_type = int; // or string, or Foo, or any other type
void* data = ...;
my_type* a = (my_type*) data;
I know that 99.9% of the time there's a better way to do what you want without resorting to casting void pointers, but I'm curious if C++ allows this sort of thing.
I would like my page action to be activated for all the outgoing links from a certain page. How might I go about doing that? I've gone over the docs to no avail. Any pointers would be appreciated!
what is the difference between a variable declared as an auto and static?
what is the difference in allocation of memory in auto and static variable?
why do we use static with array of pointers and what is its significance?
Is there any possibility to copy variable by reference no matter if its int or class instance?
My goal is to have two lists of the same objects and when one changes, change is visible in second.
In other words i need pointers:/
Google doesn't want to help!
I'm able to calculate z-scores, and we are trying to produce a function that given a z-score gives us a percent of the population in a normal distribution that would be under that z-score. All I can find are references to z-score to percentage tables.
Any pointers?
For example, "Don't return objects by value if they are expensive to copy" (RVO can't always be used). This advice might change because of rvalue references.
The same might be said about storing collections of pointers to objects, because copying them by value into the collection was too expensive; this reason might no longer be valid.
Or the use of enums might be discouraged in favour of "enum class".
What other practices or tips will change?
Read this question today about safe and unsafe code I then read about it in MSDN but I still don't understand it. Why would you want to use pointers in C#? Is this purely for speed?
Hi everyone, I'm trying to find an elegant way in Coffeescript to merge an array of arrays, so that [[1,2,3],[4,5,6],[7,8,9]] == [1,2,3,4,5,6,7,8,9].
As you might imagine, I need this because I'm generating arrays from a function in a "for in" construct and need to concatenate the resulting nested array:
result = (generate_array(x) for x in arr)
Is there an elegant way to handle this? Thanks for any pointers!
In the code I am writing I need a foo(int, char*) and a foo(int, int) functions.
If I was coding this in C++ I would use templates. Is there any equivalent for C? Or should I use void pointers? How?
Thanks.
Hi,
I've seen an interesting image hover effect being used a lot lately and was wondering whether anyone has any tips or advice on how best to create this effect?
What I'd like to create is a hover effect, so that when you hover over an image, the image fades and a magnifying glass or similar icon fades in. Highlighting the fact that if you click the image, it will enlarge etc.
Here is a nice example of the effect: http://themes.mysitemyway.com/infocus/gallery/portfolio/
Any advice or pointers would be greatly appreciated.
If I have a class that contains a std::list<Foo>, how can I implement iterators to a Foo* collection, preferably without using boost?
I'd rather not maintain a parallel collection of pointers. For now I have std::list<Foo>, mostly so that removing or inserting an element does not invalidate all other iterators, but would it be possible to implement other iterators too, so that the collection type used in the implementation is opaque to the user of the class?
I want to create a asp.net application which can show directions in a layout from room A to room B. So layout would be a grid of rooms and if the user wants to get directions from room A to room B the application to highlight the path in blue.
I have no idea how to begin with this? What can i use to create a floor layout and then highlight the required path. Any pointers ? Thanks.
Given: LDAP stores location of users.
How do I drive their timezones using their location? Any pointers are accepted, Java language preferred.
Thanks in advance.
The option to target another version of the .Net Framework is disabled on a particular test system we are using on a current project.
I have tried the following without success:
Killing all W3WP.EXE processesRestarting the IIS serviceRemote Debugging has been removed from the box.
Just hoping for some pointers.
Hi,
I came across this rather unusual usage of 'delete'. Just wanted to know if the following line deletes both pointers or only the first?
delete ptr1, ptr2