added: to Space:

std::wstring & FindAdd(const WTextStream & name);
       std::wstring & Add(const wchar_t * name,        const WTextStream & value);
       std::wstring & Add(const std::wstring & name,   const WTextStream & value);
       std::wstring & Add(const WTextStream & name,    const WTextStream & value);




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@430 e52654a7-88a9-db11-a3e9-0013d4bc506e
master
Tomasz Sowa 11 years ago
parent f8d5a962ed
commit 5ad48470b6

@ -1,6 +1,10 @@
# DO NOT DELETE
jsontospaceparser.o: jsontospaceparser.h space.h ../utf8/utf8.h
space.o: space.h ../utf8/utf8.h
spaceparser.o: spaceparser.h space.h ../utf8/utf8.h
spacetojson.o: spacetojson.h space.h
jsontospaceparser.o: jsontospaceparser.h space.h ../textstream/types.h
jsontospaceparser.o: ../utf8/utf8.h
space.o: space.h ../textstream/types.h ../utf8/utf8.h
space.o: ../textstream/textstream.h ../space/space.h ../date/date.h
space.o: ../convert/convert.h ../convert/inttostr.h ../membuffer/membuffer.h
space.o: ../textstream/types.h
spaceparser.o: spaceparser.h space.h ../textstream/types.h ../utf8/utf8.h
spacetojson.o: spacetojson.h space.h ../textstream/types.h

@ -39,6 +39,7 @@
#include <wchar.h>
#include "space.h"
#include "utf8/utf8.h"
#include "textstream/textstream.h"
@ -396,6 +397,22 @@ return *value;
}
std::wstring & Space::FindAdd(const WTextStream & name)
{
name.to_string(tmp_name);
std::wstring * value = GetValue(tmp_name);
if( !value )
{
value = &table_single[tmp_name];
table.erase(tmp_name);
}
return *value;
}
std::wstring & Space::Add(const wchar_t * name, bool value)
{
if( value )
@ -503,6 +520,46 @@ return val;
}
std::wstring & Space::Add(const wchar_t * name, const WTextStream & value)
{
tmp_name = name;
value.to_string(tmp_value_text, true);
std::wstring & val = table_single[tmp_name];
val = tmp_value_text;
return val;
}
std::wstring & Space::Add(const std::wstring & name, const WTextStream & value)
{
tmp_name = name;
value.to_string(tmp_value_text, true);
std::wstring & val = table_single[tmp_name];
val = tmp_value_text;
return val;
}
std::wstring & Space::Add(const WTextStream & name, const WTextStream & value)
{
name.to_string(tmp_name, true);
value.to_string(tmp_value_text, true);
std::wstring & val = table_single[tmp_name];
val = tmp_value_text;
return val;
}
void Space::Remove(const wchar_t * name)
{

@ -41,6 +41,8 @@
#include <string>
#include <vector>
#include <map>
#include "textstream/types.h"
namespace PT
@ -215,6 +217,7 @@ public:
std::wstring & FindAdd(const wchar_t * name);
std::wstring & FindAdd(const std::wstring & name);
std::wstring & FindAdd(const WTextStream & name);
std::wstring & Add(const wchar_t * name, bool value);
std::wstring & Add(const std::wstring & name, bool value);
@ -228,6 +231,10 @@ public:
std::wstring & Add(const wchar_t * name, const std::wstring & value);
std::wstring & Add(const std::wstring & name, const std::wstring & value);
std::wstring & Add(const wchar_t * name, const WTextStream & value);
std::wstring & Add(const std::wstring & name, const WTextStream & value);
std::wstring & Add(const WTextStream & name, const WTextStream & value);
void Remove(const wchar_t * name);
void Remove(const std::wstring & name);
@ -343,8 +350,6 @@ private:
template<class Stream>
void Space::PrintLevel(Stream & out, bool use_indents, int level)
{
@ -498,6 +503,7 @@ void Space::Serialize(Stream & out, bool use_indents, bool use_comments, int lev
}
} // namespace

@ -197,8 +197,7 @@ bool is_special;
PrintToken(out, i2->first);
out << L": ";
if( i2->second.size() != 1 )
out << '[';
out << '[';
for(v = 0 ; v < i2->second.size() ; ++v)
{
@ -211,8 +210,7 @@ bool is_special;
out << L",\n";
}
if( i2->second.size() != 1 )
out << ']';
out << ']';
if( index + 1 < space.table.size() )
out << ',';

@ -43,6 +43,8 @@
#include "date/date.h"
#include "convert/convert.h"
#include "membuffer/membuffer.h"
#include "types.h"
// for sprintf
#include <cstdio>
@ -120,8 +122,6 @@ public:
};
typedef TextStreamBase<char, 256, 4096> TextStream;
typedef TextStreamBase<wchar_t, 256, 4096> WTextStream;

@ -0,0 +1,61 @@
/*
* This file is a part of PikoTools
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef headerfile_picotools_space_types
#define headerfile_picotools_space_types
namespace PT
{
template<typename char_type, size_t stack_size, size_t heap_block_size>
class TextStreamBase;
typedef TextStreamBase<char, 256, 4096> TextStream;
typedef TextStreamBase<wchar_t, 256, 4096> WTextStream;
} // namespace
#endif
Loading…
Cancel
Save