aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-01-23 16:44:10 +0000
committerMike Buland <eichlan@xagasoft.com>2008-01-23 16:44:10 +0000
commit51f9aa16cbdd78c0b31483df26d0f7e81376f974 (patch)
treed00b95cbcd607fc4d6a70d133794d69b99491d55
parent1ea5bd399b081b598435e52854107bc506640a28 (diff)
downloadlibbu++-51f9aa16cbdd78c0b31483df26d0f7e81376f974.tar.gz
libbu++-51f9aa16cbdd78c0b31483df26d0f7e81376f974.tar.bz2
libbu++-51f9aa16cbdd78c0b31483df26d0f7e81376f974.tar.xz
libbu++-51f9aa16cbdd78c0b31483df26d0f7e81376f974.zip
Added a new helper to the Stream classes, a write function that takes a single
Bu::FString reference as a parameter. Unfortunately you need to remember to add "using Stream::write;" to each child class so they can take advantage of it. Strange, no? Also, cleaned up a bunch of header files, I'm trying to move towards headers only including other headers that they absolutely need, otherwise just creating forward decleration sections at the top of each.
Diffstat (limited to '')
-rw-r--r--src/archive.cpp2
-rw-r--r--src/archive.h5
-rw-r--r--src/fstring.h2
-rw-r--r--src/membuf.h1
-rw-r--r--src/minimacro.cpp10
-rw-r--r--src/minimacro.h2
-rw-r--r--src/socket.h1
-rw-r--r--src/stdstream.h1
-rw-r--r--src/stream.cpp7
-rw-r--r--src/stream.h4
-rw-r--r--src/tafwriter.cpp4
-rw-r--r--src/tafwriter.h9
12 files changed, 42 insertions, 6 deletions
diff --git a/src/archive.cpp b/src/archive.cpp
index 78fa362..d11f853 100644
--- a/src/archive.cpp
+++ b/src/archive.cpp
@@ -6,6 +6,8 @@
6 */ 6 */
7 7
8#include "bu/archive.h" 8#include "bu/archive.h"
9#include "bu/stream.h"
10#include "bu/archival.h"
9 11
10Bu::Archive::Archive( Stream &rStream, bool bLoading ) : 12Bu::Archive::Archive( Stream &rStream, bool bLoading ) :
11 bLoading( bLoading ), 13 bLoading( bLoading ),
diff --git a/src/archive.h b/src/archive.h
index 2d95285..fbd971e 100644
--- a/src/archive.h
+++ b/src/archive.h
@@ -10,8 +10,6 @@
10 10
11#include <stdint.h> 11#include <stdint.h>
12#include <string> 12#include <string>
13#include "bu/archival.h"
14#include "bu/stream.h"
15#include <list> 13#include <list>
16#include "bu/hash.h" 14#include "bu/hash.h"
17#include "bu/list.h" 15#include "bu/list.h"
@@ -19,6 +17,9 @@
19 17
20namespace Bu 18namespace Bu
21{ 19{
20 class Archival;
21 class Stream;
22
22 /** 23 /**
23 * Provides a framework for serialization of objects and primitives. The 24 * Provides a framework for serialization of objects and primitives. The
24 * archive will handle any basic primitive, a few special types, like char * 25 * archive will handle any basic primitive, a few special types, like char *
diff --git a/src/fstring.h b/src/fstring.h
index fd75892..49ec77e 100644
--- a/src/fstring.h
+++ b/src/fstring.h
@@ -16,7 +16,9 @@
16#include "bu/archive.h" 16#include "bu/archive.h"
17#include "bu/hash.h" 17#include "bu/hash.h"
18 18
19#ifndef min
19#define min( a, b ) ((a<b)?(a):(b)) 20#define min( a, b ) ((a<b)?(a):(b))
21#endif
20 22
21/* I borrowed this from someone who borrowed it from glib who borrowed it 23/* I borrowed this from someone who borrowed it from glib who borrowed it
22 * from... 24 * from...
diff --git a/src/membuf.h b/src/membuf.h
index 1a2abe4..a8caa16 100644
--- a/src/membuf.h
+++ b/src/membuf.h
@@ -34,6 +34,7 @@ namespace Bu
34 * of our bases for now. 34 * of our bases for now.
35 */ 35 */
36 virtual size_t write( const void *pBuf, size_t nBytes ); 36 virtual size_t write( const void *pBuf, size_t nBytes );
37 using Stream::write;
37 virtual long tell(); 38 virtual long tell();
38 virtual void seek( long offset ); 39 virtual void seek( long offset );
39 virtual void setPos( long pos ); 40 virtual void setPos( long pos );
diff --git a/src/minimacro.cpp b/src/minimacro.cpp
index 374b7de..2bd156c 100644
--- a/src/minimacro.cpp
+++ b/src/minimacro.cpp
@@ -132,3 +132,13 @@ void Bu::MiniMacro::addVar(
132 hVars.insert( sName, sValue ); 132 hVars.insert( sName, sValue );
133} 133}
134 134
135bool Bu::MiniMacro::hasVar( const Bu::FString &sName )
136{
137 return hVars.has( sName );
138}
139
140const Bu::FString &Bu::MiniMacro::getvar( const Bu::FString &sName )
141{
142 return hVars.get( sName );
143}
144
diff --git a/src/minimacro.h b/src/minimacro.h
index 105a117..4349b19 100644
--- a/src/minimacro.h
+++ b/src/minimacro.h
@@ -68,6 +68,8 @@ namespace Bu
68 68
69 Bu::FString parse( const Bu::FString &sIn ); 69 Bu::FString parse( const Bu::FString &sIn );
70 void addVar( const Bu::FString &sName, const Bu::FString &sValue ); 70 void addVar( const Bu::FString &sName, const Bu::FString &sValue );
71 bool hasVar( const Bu::FString &sName );
72 const Bu::FString &getvar( const Bu::FString &sName );
71 73
72 private: 74 private:
73 const char *sCur; 75 const char *sCur;
diff --git a/src/socket.h b/src/socket.h
index 1f1e929..b09f911 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -34,6 +34,7 @@ namespace Bu
34 virtual size_t write( const void *pBuf, size_t nBytes ); 34 virtual size_t write( const void *pBuf, size_t nBytes );
35 virtual size_t write( const void *pBuf, size_t nBytes, 35 virtual size_t write( const void *pBuf, size_t nBytes,
36 uint32_t nSec, uint32_t nUSec=0 ); 36 uint32_t nSec, uint32_t nUSec=0 );
37 using Stream::write;
37 38
38 virtual long tell(); 39 virtual long tell();
39 virtual void seek( long offset ); 40 virtual void seek( long offset );
diff --git a/src/stdstream.h b/src/stdstream.h
index ccfb28a..15ac875 100644
--- a/src/stdstream.h
+++ b/src/stdstream.h
@@ -23,6 +23,7 @@ namespace Bu
23 virtual void close(); 23 virtual void close();
24 virtual size_t read( void *pBuf, size_t nBytes ); 24 virtual size_t read( void *pBuf, size_t nBytes );
25 virtual size_t write( const void *pBuf, size_t nBytes ); 25 virtual size_t write( const void *pBuf, size_t nBytes );
26 using Stream::write;
26 virtual long tell(); 27 virtual long tell();
27 virtual void seek( long offset ); 28 virtual void seek( long offset );
28 virtual void setPos( long pos ); 29 virtual void setPos( long pos );
diff --git a/src/stream.cpp b/src/stream.cpp
index 8d976e5..82fe73b 100644
--- a/src/stream.cpp
+++ b/src/stream.cpp
@@ -5,7 +5,7 @@
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7 7
8#include "stream.h" 8#include "bu/stream.h"
9 9
10Bu::Stream::Stream() 10Bu::Stream::Stream()
11{ 11{
@@ -15,3 +15,8 @@ Bu::Stream::~Stream()
15{ 15{
16} 16}
17 17
18size_t Bu::Stream::write( const Bu::FString &sBuf )
19{
20 return write( sBuf.getStr(), sBuf.getSize() );
21}
22
diff --git a/src/stream.h b/src/stream.h
index 078c045..f3cd882 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -11,6 +11,8 @@
11#include <stdint.h> 11#include <stdint.h>
12#include <stdio.h> 12#include <stdio.h>
13 13
14#include "bu/fstring.h"
15
14namespace Bu 16namespace Bu
15{ 17{
16 /** 18 /**
@@ -50,6 +52,8 @@ namespace Bu
50 */ 52 */
51 virtual size_t write( const void *pBuf, size_t nBytes ) = 0; 53 virtual size_t write( const void *pBuf, size_t nBytes ) = 0;
52 54
55 virtual size_t write( const Bu::FString &sBuf );
56
53 /** 57 /**
54 * Get the current position in the stream. 58 * Get the current position in the stream.
55 *@returns (long) The current position in the stream. 59 *@returns (long) The current position in the stream.
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp
index 3a33b11..9abaea4 100644
--- a/src/tafwriter.cpp
+++ b/src/tafwriter.cpp
@@ -5,7 +5,9 @@
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7 7
8#include "tafwriter.h" 8#include "bu/tafwriter.h"
9#include "bu/tafnode.h"
10#include "bu/stream.h"
9 11
10Bu::TafWriter::TafWriter( Bu::Stream &sOut ) : 12Bu::TafWriter::TafWriter( Bu::Stream &sOut ) :
11 sOut( sOut ), 13 sOut( sOut ),
diff --git a/src/tafwriter.h b/src/tafwriter.h
index 08c1832..ca0de37 100644
--- a/src/tafwriter.h
+++ b/src/tafwriter.h
@@ -9,12 +9,17 @@
9#define BU_TAF_WRITER_H 9#define BU_TAF_WRITER_H
10 10
11#include <stdint.h> 11#include <stdint.h>
12#include "bu/tafnode.h" 12
13#include "bu/stream.h"
14#include "bu/fstring.h" 13#include "bu/fstring.h"
15 14
16namespace Bu 15namespace Bu
17{ 16{
17 class Stream;
18 class TafNode;
19 class TafGroup;
20 class TafProperty;
21 class TafComment;
22
18 /** 23 /**
19 * 24 *
20 *@ingroup Taf 25 *@ingroup Taf