Using C++, I would like to use a command/class to get the latency time from pinging a host to use in my program. I tried using the ping command but there was no easy way to gather the time since its included with other statistical information. I was hoping for an easier approach.
...
I have a template class for thread-safe vector:
template <class T>
class SharedVector {
std::vector<T> vect;
CRITICAL_SECTION cs;
SharedVector(const SharedVector<T>& rhs) {}
public:
typedef typename std::vector<T>::size_type SizeType;
SharedVector();
void PushBack(const T& value);
void PopBack();
SizeType...
On our embedded device, we currently use PHP for its web interface, and unfortunately it's quite slow. We've been experimenting with Python, but is seems (at least on FPU-less ARM architecture) to be as slow as PHP.
Therefore we're thinking about implementing web interface in some compiled language like C++, but so far the only thing we...
So I was just working with function pointers and I remembered that you could do this:
void Foo()
{
}
int main()
{
void(& func)() = Foo;
func(); //::Foo();
}
The obvious advantage being that references reference valid objects (unless they're misused), or functions in this case.
The obvious disadvantages being that you can't ...
I have a logger system which basically is a fancy way of writing my data to std::clog in a thread safe way.
I also, redirect std::clog to a file like this:
int main() {
std::ofstream logfile(config::logname, std::ios::app);
std::streambuf *const old_buffer = std::clog.rdbuf(logfile.rdbuf());
// .. the guts of the applicat...
I open a FIFO file as ifstream. As soon as the object is created the thread is blocked until I send something into the FIFO (which is OK for me). I then call getline() to get the data from stream.
How do I read-block the thread again until more data is written into FIFO file?
Thanks
...
A customer is complaining that our code used to write files with Japanese characters in the filename but no longer works in all cases. We have always just used good old char * strings to represent filenames, so it came as a bit of a shock to me that it ever worked, and we haven't done anything I am aware of that should have made it stop...
So, I have this situation where I need to see if an object is in my stl map. If it isn't, I am going to add it.
char symbolName[] = { 'H', 'e', 'l', 'l', 'o', '\0' };
map<string,TheObject> theMap;
if (theMap.find(symbolName)==theMap.end()) {
TheObject theObject(symbolName);
theMap.insert(pair<string, TheObject>(symbolName,
...
As part of a numerical library test I need to choose base 10 decimal numbers that can be represented exactly in base 2. How do you detect in C++ if a base 10 decimal number can be represented exactly in base 2?
My first guess is as follows:
bool canBeRepresentedInBase2(const double &pNumberInBase10)
{
//check if a number in base 10...
How long should it take an average coder (has used C/C++ but isn't an expert) to understand what a buffer overflow is, why its a bad thing, and how someone might use it to take control of the application?
...
Implemented the Sink Class - to receive event notifications from COM Server
Event Interface derives from IDispatch
I have an issue whereby an IConnectionPoint::Advise call returns E_NOTIMPL. This could be because the connection point only allows one connection - MSDN.
Note:
COM Server is out-of-process
Pure C++ implementation
EDI...
I'm having difficulty in using std::for_each and other algorithms with a multimap, and want to know if someone could help me developing a functor that could pass the appropriate parameter to the "generic" functions.
My specific problem with map/multimap is that their iterators evaluate to a std::pair instead of the contained value (I me...
Suppose we have the following class hierarchy:
class Base {
...
};
class Derived1 : public Base {
...
};
class Derived2 : public Base {
...
};
Given a Base* which could point to either a Derived1 or Derived2 object how can I make a copy of the actual object given that it's concrete type is unknown. I thought of defining ...
My current code to the effect of:
if( objectPointer != NULL){
delete objectPointer;
}
doesn't work because the pointers are getting set to invalid hex numbers by the compiler such as:
0xbaadf00d
0xdeadbeef
etc....
So what's the best way to check for an invalid pointer before trying to delete the object?
...
If you have a simple enough schema with basic boolean string fields, how to go about writing a code generator in C++.
If you ever wrote , how did you start. Articles/recommendation welcome.
EDIT: Note that this is not the standard CORBA idl.
...
Since C++ seems to have all of C's features, why learn C over C++?
...
Is there a good ORM (object relational manager) solution that can use the same database from C++, C#, Python?
It could also be multiple solutions, e.g. one per language, as long as they can can access the same database and use the same schema.
Multi platform support is also needed.
Clarification:
The idea is to have one database and ...
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html
SIGINT is generally used/cause by the user. How do i cause a SIGINT in c++? i seen an example using kill(pid, SIGINT); but i rather cause it another way. Also i am using windows.
...
I overloaded the 6 signals listed on this site http://www.cplusplus.com/reference/clibrary/csignal/signal.html
Then i ran my app (double click not ran through IDE) and tried 1) end task 2) X on topright and 3) kill process. I expected the first two to cause some kind of signal (i am on XP) but alas i got nothing. Am i not allowed to ope...
Often, one needs several enumerated types together. Sometimes, one has a name clash. Two solutions to this come to mind: use a namespace, or use 'larger' enum element names. Still, the namespace solution has to possible implementations: a dummy class with nested enum, or a full blown namespace.
I'm looking for pro's and con's of all ...