some modifications for libcflie

That's what I've did while creating a headless client for the  Crazyflie:
https://github.com/aholler/crazyflie-client-cpp 
Am 27.10.2014 23:34, schrieb Jan Winkler:
>> +    std::cout << "foo" << std::endl;
>> +    return;
>> +  }
>> +  const char *cData = packet.payload();
>> +  bool bFound;
>> +  int nBlockID = cData[1];
>> +  struct LoggingBlock lbCurrent = loggingBlockForID(nBlockID, bFound);
>> +  if(!bFound)
>> +    throw std::runtime_error("Unknown logging block");
>> +  unsigned nOffset = 0;
>> +  unsigned nByteLength;
>> +  for(unsigned nIndex = 0; nIndex < lbCurrent.lstElementIDs.size(); ++nIndex, nOffset += nByteLength) {
>> +    int id = elementIDinBlock(nBlockID, nIndex);
>> +    auto i = std::find_if(m_lstTOCElements.begin(), m_lstTOCElements.end(), [id] (TOCElement e) { return e.nID == id; });
>> +    if (i == m_lstTOCElements.end())
>> +      throw std::runtime_error("Unknown log element");
>
> I specifically did not use exceptions throughout the whole library. This can be solved with a clean `if` statement. Is there a reason to use exceptions over conditionals here?
>
> Conditionals form a much cleaner program flow, whereas exceptions break the program flow. I see that both styles exist and have their applications, but since there is no need for exception throwing here, I'd like to keep them out of the code.

The reason I've decided to use exceptions here is the same as why 
assert() is often used: to make the developer aware that something is 
havily broken without the need for unnecessary if statements in multiple 
locations (all the callers).

E.g. take this short excerpt from cfheadless.cpp:

-------------
	cflieCopter.getParameterValue("firmware.revision0", fw_rev0);
	cflieCopter.getParameterValue("firmware.revision1", fw_rev1);
	cflieCopter.getParameterValue("firmware.modified", fw_dirty);
-------------

Without exceptions in getParameterValue() that would have to look like:

-------------
	if (cflieCopter.getParameterValue("firmware.revision0", fw_rev0))
		std::cerr << "Some error\n";
	if (cflieCopter.getParameterValue("firmware.revision1", fw_rev1))
		std::cerr << "Same error?\n";
	if (cflieCopter.getParameterValue("firmware.modified", fw_dirty)=
		std::cerr << "Another error?\n";
-------------

or even uglier:

-------------
	int rc = cflieCopter.getParameterValue("firmware.revision0", fw_rev0);
	switch (rc) {
		...
	}
	rc = cflieCopter.getParameterValue("firmware.revision1", fw_rev1);
	switch (rc) {
		...
	}
	rc = cflieCopter.getParameterValue("firmware.modified", fw_dirty);
	switch (rc) {
		...
	}
-------------

So using exceptions on central locations avoids all the error handling 
in their callers, especially if stoping the program doesn't end up in 
something really bad.

And, as said in the description, if something bad happens, we've most 
likely already have lost control over the Crazyflie.

And there still several places more where currently errors are just 
ignored, which ends up with the problem, that they might not be 
recognized by the developer at all, which then might lead to other 
errors, not showing the real problem.