]> git.tdb.fi Git - libs/core.git/blobdiff - source/buffered.cpp
Style update: spaces around assignments
[libs/core.git] / source / buffered.cpp
index 32688db83618d874652fd0926a8d556648e765d7..b8a2dbee7255628fa899c691cac3b041e94f164a 100644 (file)
@@ -22,7 +22,7 @@ Buffered::Buffered(Base &b, unsigned s):
        end(buf),
        cur_op(M_NONE)
 {
-       mode=below.get_mode();
+       mode = below.get_mode();
        below.signal_flush_required.connect(sigc::mem_fun(this, &Buffered::flush));
 }
 
@@ -32,7 +32,7 @@ unsigned Buffered::put(char c)
 
        if(end<buf+buf_size)
        {
-               *end++=c;
+               *end++ = c;
                return 1;
        }
        else
@@ -43,19 +43,19 @@ void Buffered::flush()
 {
        if(cur_op==M_WRITE)
        {
-               unsigned used=end-begin;
+               unsigned used = end-begin;
                if(used)
                {
-                       unsigned len=below.write(begin, used);
+                       unsigned len = below.write(begin, used);
 
-                       begin=end=buf;
+                       begin=end = buf;
 
                        if(len<used)
                                throw Exception("Couldn't flush all data");
                }
        }
        else if(cur_op==M_READ)
-               begin=end=buf;
+               begin=end = buf;
 }
 
 bool Buffered::getline(std::string &line)
@@ -66,7 +66,7 @@ bool Buffered::getline(std::string &line)
                if(*i=='\n')
                {
                        line.assign(begin, i-begin);
-                       begin=i+1;
+                       begin = i+1;
                        return true;
                }
 
@@ -112,7 +112,7 @@ void Buffered::set_op(Mode op)
 {
        if(op!=cur_op)
                flush();
-       cur_op=op;
+       cur_op = op;
 }
 
 unsigned Buffered::do_write(const char *data, unsigned size)
@@ -123,7 +123,7 @@ unsigned Buffered::do_write(const char *data, unsigned size)
        {
                // All data fits in buffer with whatever is already there
                memcpy(end, data, size);
-               end+=size;
+               end += size;
 
                return size;
        }
@@ -136,7 +136,7 @@ unsigned Buffered::do_write(const char *data, unsigned size)
                {
                        // Put new data in the buffer to wait for more
                        memcpy(end, data, size);
-                       end+=size;
+                       end += size;
 
                        return size;
                }
@@ -154,9 +154,9 @@ unsigned Buffered::do_read(char *data, unsigned size)
        {
                // The request can be served from the buffer
                memcpy(data, begin, size);
-               begin+=size;
+               begin += size;
 
-               eof_flag=(below.eof() && begin==end);
+               eof_flag = (below.eof() && begin==end);
 
                return size;
        }
@@ -164,28 +164,28 @@ unsigned Buffered::do_read(char *data, unsigned size)
        {
                // Give out whatever is in the buffer already
                memcpy(data, begin, end-begin);
-               unsigned ret=end-begin;
-               begin=end=buf;
+               unsigned ret = end-begin;
+               begin=end = buf;
 
-               data+=ret;
-               size-=ret;
+               data += ret;
+               size -= ret;
 
                if(size<buf_size)
                {
                        // Fill the buffer and serve the rest of the request from it
-                       unsigned len=below.read(end, buf+buf_size-end);
-                       end+=len;
+                       unsigned len = below.read(end, buf+buf_size-end);
+                       end += len;
 
-                       len=min(static_cast<unsigned>(end-begin), size);
+                       len = min(static_cast<unsigned>(end-begin), size);
                        memcpy(data, begin, len);
-                       begin+=len;
-                       ret+=len;
+                       begin += len;
+                       ret += len;
                }
                else
                        // Read the rest directly from the underlying object
-                       ret+=below.read(data, size);
+                       ret += below.read(data, size);
 
-               eof_flag=(below.eof() && begin==end);
+               eof_flag = (below.eof() && begin==end);
 
                return ret;
        }