Converted some for loops to range-based for loops.
This commit is contained in:
parent
0000fa3e5e
commit
9d2bfcc334
|
@ -103,8 +103,8 @@ int main()
|
||||||
sf::Ftp::ListingResponse response = server.getDirectoryListing();
|
sf::Ftp::ListingResponse response = server.getDirectoryListing();
|
||||||
std::cout << response << std::endl;
|
std::cout << response << std::endl;
|
||||||
const std::vector<std::string>& names = response.getListing();
|
const std::vector<std::string>& names = response.getListing();
|
||||||
for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
|
for (const auto& name : names)
|
||||||
std::cout << *it << std::endl;
|
std::cout << name << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ template <typename T>
|
||||||
void SoundFileFactory::unregisterReader()
|
void SoundFileFactory::unregisterReader()
|
||||||
{
|
{
|
||||||
// Remove the instance(s) of the reader from the array of factories
|
// Remove the instance(s) of the reader from the array of factories
|
||||||
for (ReaderFactoryArray::iterator it = s_readers.begin(); it != s_readers.end(); )
|
for (auto it = s_readers.begin(); it != s_readers.end(); )
|
||||||
{
|
{
|
||||||
if (it->create == &priv::createReader<T>)
|
if (it->create == &priv::createReader<T>)
|
||||||
it = s_readers.erase(it);
|
it = s_readers.erase(it);
|
||||||
|
@ -88,7 +88,7 @@ template <typename T>
|
||||||
void SoundFileFactory::unregisterWriter()
|
void SoundFileFactory::unregisterWriter()
|
||||||
{
|
{
|
||||||
// Remove the instance(s) of the writer from the array of factories
|
// Remove the instance(s) of the writer from the array of factories
|
||||||
for (WriterFactoryArray::iterator it = s_writers.begin(); it != s_writers.end(); )
|
for (auto it = s_writers.begin(); it != s_writers.end(); )
|
||||||
{
|
{
|
||||||
if (it->create == &priv::createWriter<T>)
|
if (it->create == &priv::createWriter<T>)
|
||||||
it = s_writers.erase(it);
|
it = s_writers.erase(it);
|
||||||
|
|
|
@ -241,9 +241,9 @@ private:
|
||||||
/// else
|
/// else
|
||||||
/// {
|
/// {
|
||||||
/// // The listener socket is not ready, test all other sockets (the clients)
|
/// // The listener socket is not ready, test all other sockets (the clients)
|
||||||
/// for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
|
/// for (auto c : clients)
|
||||||
/// {
|
/// {
|
||||||
/// sf::TcpSocket& client = **it;
|
/// sf::TcpSocket& client = *c;
|
||||||
/// if (selector.isReady(client))
|
/// if (selector.isReady(client))
|
||||||
/// {
|
/// {
|
||||||
/// // The client has sent some data, we can receive it
|
/// // The client has sent some data, we can receive it
|
||||||
|
|
|
@ -72,8 +72,8 @@ SoundBuffer::~SoundBuffer()
|
||||||
sounds.swap(m_sounds);
|
sounds.swap(m_sounds);
|
||||||
|
|
||||||
// Detach the buffer from the sounds that use it (to avoid OpenAL errors)
|
// Detach the buffer from the sounds that use it (to avoid OpenAL errors)
|
||||||
for (SoundList::const_iterator it = sounds.begin(); it != sounds.end(); ++it)
|
for (const auto& sound : sounds)
|
||||||
(*it)->resetBuffer();
|
sound->resetBuffer();
|
||||||
|
|
||||||
// Destroy the buffer
|
// Destroy the buffer
|
||||||
if (m_buffer)
|
if (m_buffer)
|
||||||
|
@ -257,8 +257,8 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
|
||||||
SoundList sounds(m_sounds);
|
SoundList sounds(m_sounds);
|
||||||
|
|
||||||
// Detach the buffer from the sounds that use it (to avoid OpenAL errors)
|
// Detach the buffer from the sounds that use it (to avoid OpenAL errors)
|
||||||
for (SoundList::const_iterator it = sounds.begin(); it != sounds.end(); ++it)
|
for (const auto& sound : sounds)
|
||||||
(*it)->resetBuffer();
|
sound->resetBuffer();
|
||||||
|
|
||||||
// Fill the buffer
|
// Fill the buffer
|
||||||
ALsizei size = static_cast<ALsizei>(m_samples.size()) * sizeof(Int16);
|
ALsizei size = static_cast<ALsizei>(m_samples.size()) * sizeof(Int16);
|
||||||
|
@ -268,8 +268,8 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
|
||||||
m_duration = seconds(static_cast<float>(m_samples.size()) / sampleRate / channelCount);
|
m_duration = seconds(static_cast<float>(m_samples.size()) / sampleRate / channelCount);
|
||||||
|
|
||||||
// Now reattach the buffer to the sounds that use it
|
// Now reattach the buffer to the sounds that use it
|
||||||
for (SoundList::const_iterator it = sounds.begin(); it != sounds.end(); ++it)
|
for (const auto& sound : sounds)
|
||||||
(*it)->setBuffer(*this);
|
sound->setBuffer(*this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,11 @@ std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromFilename(cons
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the filename in all the registered factories
|
// Test the filename in all the registered factories
|
||||||
for (ReaderFactoryArray::const_iterator it = s_readers.begin(); it != s_readers.end(); ++it)
|
for (const auto& reader : s_readers)
|
||||||
{
|
{
|
||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
if (it->check(stream))
|
if (reader.check(stream))
|
||||||
return it->create();
|
return reader.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No suitable reader found
|
// No suitable reader found
|
||||||
|
@ -100,11 +100,11 @@ std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromMemory(const
|
||||||
stream.open(data, sizeInBytes);
|
stream.open(data, sizeInBytes);
|
||||||
|
|
||||||
// Test the stream for all the registered factories
|
// Test the stream for all the registered factories
|
||||||
for (ReaderFactoryArray::const_iterator it = s_readers.begin(); it != s_readers.end(); ++it)
|
for (const auto& reader : s_readers)
|
||||||
{
|
{
|
||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
if (it->check(stream))
|
if (reader.check(stream))
|
||||||
return it->create();
|
return reader.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No suitable reader found
|
// No suitable reader found
|
||||||
|
@ -120,11 +120,11 @@ std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromStream(InputS
|
||||||
ensureDefaultReadersWritersRegistered();
|
ensureDefaultReadersWritersRegistered();
|
||||||
|
|
||||||
// Test the stream for all the registered factories
|
// Test the stream for all the registered factories
|
||||||
for (ReaderFactoryArray::const_iterator it = s_readers.begin(); it != s_readers.end(); ++it)
|
for (const auto& reader : s_readers)
|
||||||
{
|
{
|
||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
if (it->check(stream))
|
if (reader.check(stream))
|
||||||
return it->create();
|
return reader.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No suitable reader found
|
// No suitable reader found
|
||||||
|
@ -140,10 +140,10 @@ std::unique_ptr<SoundFileWriter> SoundFileFactory::createWriterFromFilename(cons
|
||||||
ensureDefaultReadersWritersRegistered();
|
ensureDefaultReadersWritersRegistered();
|
||||||
|
|
||||||
// Test the filename in all the registered factories
|
// Test the filename in all the registered factories
|
||||||
for (WriterFactoryArray::const_iterator it = s_writers.begin(); it != s_writers.end(); ++it)
|
for (const auto& writer : s_writers)
|
||||||
{
|
{
|
||||||
if (it->check(filename))
|
if (writer.check(filename))
|
||||||
return it->create();
|
return writer.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No suitable writer found
|
// No suitable writer found
|
||||||
|
|
|
@ -284,8 +284,8 @@ void SoundStream::streamData()
|
||||||
|
|
||||||
// Create the buffers
|
// Create the buffers
|
||||||
alCheck(alGenBuffers(BufferCount, m_buffers));
|
alCheck(alGenBuffers(BufferCount, m_buffers));
|
||||||
for (int i = 0; i < BufferCount; ++i)
|
for (auto& buffer : m_endBuffers)
|
||||||
m_endBuffers[i] = false;
|
buffer = false;
|
||||||
|
|
||||||
// Fill the queue
|
// Fill the queue
|
||||||
requestStop = fillQueue();
|
requestStop = fillQueue();
|
||||||
|
@ -337,7 +337,7 @@ void SoundStream::streamData()
|
||||||
|
|
||||||
// Find its number
|
// Find its number
|
||||||
unsigned int bufferNum = 0;
|
unsigned int bufferNum = 0;
|
||||||
for (int i = 0; i < BufferCount; ++i)
|
for (auto i = 0; i < BufferCount; ++i)
|
||||||
if (m_buffers[i] == buffer)
|
if (m_buffers[i] == buffer)
|
||||||
{
|
{
|
||||||
bufferNum = i;
|
bufferNum = i;
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern "C"
|
||||||
#include <jpeglib.h>
|
#include <jpeglib.h>
|
||||||
#include <jerror.h>
|
#include <jerror.h>
|
||||||
}
|
}
|
||||||
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +46,7 @@ namespace
|
||||||
// Convert a string to lower case
|
// Convert a string to lower case
|
||||||
std::string toLower(std::string str)
|
std::string toLower(std::string str)
|
||||||
{
|
{
|
||||||
for (std::string::iterator i = str.begin(); i != str.end(); ++i)
|
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||||
*i = static_cast<char>(std::tolower(*i));
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@ namespace
|
||||||
// Convert a string to lower case
|
// Convert a string to lower case
|
||||||
std::string toLower(std::string str)
|
std::string toLower(std::string str)
|
||||||
{
|
{
|
||||||
for (std::string::iterator i = str.begin(); i != str.end(); ++i)
|
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||||
*i = static_cast<char>(std::tolower(*i));
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,9 +118,9 @@ std::string Http::Request::prepare() const
|
||||||
out << "HTTP/" << m_majorVersion << "." << m_minorVersion << "\r\n";
|
out << "HTTP/" << m_majorVersion << "." << m_minorVersion << "\r\n";
|
||||||
|
|
||||||
// Write fields
|
// Write fields
|
||||||
for (FieldTable::const_iterator i = m_fields.begin(); i != m_fields.end(); ++i)
|
for (const auto& field : m_fields)
|
||||||
{
|
{
|
||||||
out << i->first << ": " << i->second << "\r\n";
|
out << field.first << ": " << field.second << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use an extra \r\n to separate the header from the body
|
// Use an extra \r\n to separate the header from the body
|
||||||
|
|
|
@ -544,8 +544,8 @@ Packet& Packet::operator <<(const std::wstring& data)
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
for (std::wstring::const_iterator c = data.begin(); c != data.end(); ++c)
|
for (auto c : data)
|
||||||
*this << static_cast<Uint32>(*c);
|
*this << static_cast<Uint32>(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -562,8 +562,8 @@ Packet& Packet::operator <<(const String& data)
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
for (String::ConstIterator c = data.begin(); c != data.end(); ++c)
|
for (auto c : data)
|
||||||
*this << *c;
|
*this << c;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
Loading…
Reference in a new issue