make tex2lyx lyxstring agnostic

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7222 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-06-30 11:36:08 +00:00
parent 0519b8a2f2
commit 5552f4045f
8 changed files with 40 additions and 33 deletions

View File

@ -6,7 +6,6 @@
#include <config.h> #include <config.h>
#include "Lsstream.h"
#include "tex2lyx.h" #include "tex2lyx.h"
#include <iostream> #include <iostream>
@ -15,6 +14,7 @@
using std::cerr; using std::cerr;
using std::endl; using std::endl;
using std::ostream; using std::ostream;
using std::string;
using std::vector; using std::vector;

View File

@ -6,11 +6,11 @@
#include <config.h> #include <config.h>
#include "Lsstream.h"
#include "tex2lyx.h" #include "tex2lyx.h"
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
@ -21,6 +21,7 @@ using std::istream;
using std::istringstream; using std::istringstream;
using std::ostream; using std::ostream;
using std::ostringstream; using std::ostringstream;
using std::string;
using std::vector; using std::vector;

View File

@ -6,12 +6,12 @@
#include <config.h> #include <config.h>
#include "Lsstream.h"
#include "tex2lyx.h" #include "tex2lyx.h"
#include <cctype> #include <cctype>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream>
#include <vector> #include <vector>
using std::cerr; using std::cerr;
@ -19,6 +19,7 @@ using std::endl;
using std::istringstream; using std::istringstream;
using std::ostream; using std::ostream;
using std::ostringstream; using std::ostringstream;
using std::string;
using std::vector; using std::vector;
#include "mathed/math_gridinfo.h" #include "mathed/math_gridinfo.h"
@ -27,7 +28,7 @@ namespace {
int string2int(string const & s, int deflt = 0) int string2int(string const & s, int deflt = 0)
{ {
istringstream is(STRCONV(s)); istringstream is(s);
int i = deflt; int i = deflt;
is >> i; is >> i;
return i; return i;
@ -51,7 +52,7 @@ string read_hlines(Parser & p)
}; };
//cerr << "read_hlines(), read: '" << os.str() << "'\n"; //cerr << "read_hlines(), read: '" << os.str() << "'\n";
//cerr << "read_hlines(), next token: " << p.next_token() << "\n"; //cerr << "read_hlines(), next token: " << p.next_token() << "\n";
return STRCONV(os.str()); return os.str();
} }
@ -283,7 +284,7 @@ void handle_tabular(Parser & p, ostream & os)
ostringstream ss; ostringstream ss;
ss << read_hlines(p) << HLINE; // handle initial hlines ss << read_hlines(p) << HLINE; // handle initial hlines
parse_table(p, ss, FLAG_END); parse_table(p, ss, FLAG_END);
split(STRCONV(ss.str()), lines, LINE); split(ss.str(), lines, LINE);
vector< vector<CellInfo> > cellinfo(lines.size()); vector< vector<CellInfo> > cellinfo(lines.size());
vector<RowInfo> rowinfo(lines.size()); vector<RowInfo> rowinfo(lines.size());

View File

@ -4,15 +4,13 @@
// {[( // {[(
#include <config.h>
#include "Lsstream.h"
#include "tex2lyx.h" #include "tex2lyx.h"
#include <cctype> #include <cctype>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <sstream>
#include <vector> #include <vector>
using std::cout; using std::cout;
@ -25,6 +23,7 @@ using std::istringstream;
using std::ostream; using std::ostream;
using std::ostringstream; using std::ostringstream;
using std::stringstream; using std::stringstream;
using std::string;
using std::vector; using std::vector;
@ -63,7 +62,7 @@ string const trim(string const & a, char const * p)
void split(string const & s, vector<string> & result, char delim) void split(string const & s, vector<string> & result, char delim)
{ {
//cerr << "split 1: '" << s << "'\n"; //cerr << "split 1: '" << s << "'\n";
istringstream is(STRCONV(s)); istringstream is(s);
string t; string t;
while (getline(is, t, delim)) while (getline(is, t, delim))
result.push_back(t); result.push_back(t);
@ -79,7 +78,7 @@ string join(vector<string> const & input, char const * delim)
os << delim; os << delim;
os << input[i]; os << input[i];
} }
return STRCONV(os.str()); return os.str();
} }

View File

@ -24,11 +24,13 @@ std::string parse_text(Parser & p, unsigned flags, const bool outer);
void handle_comment(Parser & p); void handle_comment(Parser & p);
std::string const trim(std::string const & a, char const * p = " \t\n\r"); std::string const trim(std::string const & a, char const * p = " \t\n\r");
void split(std::string const & s, std::vector<std::string> & result, char delim = ','); void split(std::string const & s, std::vector<std::string> & result,
std::string join(std::vector<std::string> const & input, char const * delim); char delim = ',');
std::string join(std::vector<std::string> const & input,
char const * delim);
bool is_math_env(std::string const & name); bool is_math_env(std::string const & name);
char const ** is_known(string const & str, char const ** what); char const ** is_known(std::string const & str, char const ** what);
// Access to environment stack // Access to environment stack
extern std::vector<std::string> active_environments; extern std::vector<std::string> active_environments;

View File

@ -2,9 +2,9 @@
#include <config.h> #include <config.h>
#include "texparser.h" #include "texparser.h"
#include "Lsstream.h"
#include <iostream> #include <iostream>
#include <sstream>
using std::cerr; using std::cerr;
using std::endl; using std::endl;
@ -13,6 +13,7 @@ using std::ios;
using std::istream; using std::istream;
using std::istringstream; using std::istringstream;
using std::ostream; using std::ostream;
using std::string;
using std::vector; using std::vector;
@ -126,7 +127,7 @@ Parser::Parser(istream & is)
Parser::Parser(string const & s) Parser::Parser(string const & s)
: lineno_(0), pos_(0) : lineno_(0), pos_(0)
{ {
istringstream is(STRCONV(s)); istringstream is(s);
tokenize(is); tokenize(is);
} }

View File

@ -1,12 +1,13 @@
#ifndef PARSER_H #ifndef PARSER_H
#define PARSER_H #define PARSER_H
#include "LString.h"
#include <vector> #include <vector>
#include <string>
enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE, MATHTEXT_MODE, TABLE_MODE}; enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE, MATHTEXT_MODE, TABLE_MODE};
mode_type asMode(mode_type oldmode, string const & str); mode_type asMode(mode_type oldmode, std::string const & str);
// These are TeX's catcodes // These are TeX's catcodes
@ -62,22 +63,22 @@ public:
/// ///
Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {} Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
/// ///
Token(string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {} Token(std::string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
/// ///
string const & cs() const { return cs_; } std::string const & cs() const { return cs_; }
/// ///
CatCode cat() const { return cat_; } CatCode cat() const { return cat_; }
/// ///
char character() const { return char_; } char character() const { return char_; }
/// ///
string asString() const; std::string asString() const;
/// ///
string asInput() const; std::string asInput() const;
private: private:
/// ///
string cs_; std::string cs_;
/// ///
char char_; char char_;
/// ///
@ -97,7 +98,7 @@ public:
/// ///
Parser(std::istream & is); Parser(std::istream & is);
/// ///
Parser(string const & s); Parser(std::string const & s);
/// ///
int lineno() const { return lineno_; } int lineno() const { return lineno_; }
@ -107,13 +108,13 @@ public:
void dump() const; void dump() const;
/// ///
string getArg(char left, char right); std::string getArg(char left, char right);
/// getArg('[', ']') including the brackets /// getArg('[', ']') including the brackets
string getOpt(); std::string getOpt();
/// ///
char getChar(); char getChar();
/// ///
void error(string const & msg); void error(std::string const & msg);
/// ///
void tokenize(std::istream & is); void tokenize(std::istream & is);
/// ///
@ -129,13 +130,13 @@ public:
/// skips spaces if any /// skips spaces if any
void skip_spaces(); void skip_spaces();
/// ///
void lex(string const & s); void lex(std::string const & s);
/// ///
bool good() const; bool good() const;
/// ///
string verbatim_item(); std::string verbatim_item();
/// ///
string verbatimOption(); std::string verbatimOption();
/// ///
void setCatCode(char c, CatCode cat); void setCatCode(char c, CatCode cat);
@ -151,4 +152,5 @@ public:
unsigned pos_; unsigned pos_;
}; };
#endif #endif

View File

@ -6,11 +6,11 @@
#include <config.h> #include <config.h>
#include "Lsstream.h"
#include "tex2lyx.h" #include "tex2lyx.h"
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <sstream>
#include <vector> #include <vector>
using std::cerr; using std::cerr;
@ -18,6 +18,7 @@ using std::endl;
using std::map; using std::map;
using std::ostream; using std::ostream;
using std::ostringstream; using std::ostringstream;
using std::string;
using std::vector; using std::vector;
@ -596,7 +597,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer)
ss << "\\fancyhead"; ss << "\\fancyhead";
ss << p.getOpt(); ss << p.getOpt();
ss << '{' << p.verbatim_item() << "}\n"; ss << '{' << p.verbatim_item() << "}\n";
handle_ert(os, STRCONV(ss.str())); handle_ert(os, ss.str());
} }
else { else {
@ -628,7 +629,7 @@ string parse_text(Parser & p, unsigned flags, const bool outer)
{ {
ostringstream os; ostringstream os;
parse_text(p, os, flags, outer); parse_text(p, os, flags, outer);
return STRCONV(os.str()); return os.str();
} }