mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Those parts of Herbert's natbib patch that either fix bugs or just move
functions around. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3995 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c9265e7ccb
commit
9b3f8c9819
@ -1,3 +1,13 @@
|
||||
2002-04-14 Herbert Voss <voss@perce.de>
|
||||
|
||||
* helper_funcs.[Ch]: move the getVectorFromString and the vice versa
|
||||
into the support/lstrings for better use in other programs.
|
||||
|
||||
* biblio.[Ch] (getYear, getAbbreviatedAuthor, familyName): move out of
|
||||
namespace anon and make globally accessible.
|
||||
(familyName): test for the presence of a LaTeX Space at the front of
|
||||
of a name; strip it if it exists.
|
||||
|
||||
2002-04-11 Herbert Voss <voss@perce.de>
|
||||
|
||||
* ControlGraphics.C: expand "browse-string" to all available formats
|
||||
|
@ -142,6 +142,10 @@ regexSearch(InfoMap const & theMap,
|
||||
return keys.end();
|
||||
}
|
||||
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
string const familyName(string const & name)
|
||||
{
|
||||
// Very simple parser
|
||||
@ -158,6 +162,9 @@ string const familyName(string const & name)
|
||||
idx = fname.rfind(".");
|
||||
if (idx != string::npos)
|
||||
fname = frontStrip(fname.substr(idx+1));
|
||||
// test if we have a LaTeX Space in front
|
||||
if (fname[0] == '\\')
|
||||
return fname.substr(2);
|
||||
|
||||
return fname;
|
||||
}
|
||||
@ -217,9 +224,6 @@ string const getYear(InfoMap const & map, string const & key)
|
||||
return year;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
// A functor for use with std::sort, leading to case insensitive sorting
|
||||
struct compareNoCase: public std::binary_function<string, string, bool>
|
||||
|
@ -60,6 +60,15 @@ namespace biblio
|
||||
Empty if no info exists. */
|
||||
string const getInfo(InfoMap const &, string const &);
|
||||
|
||||
// rturn the year from the bibtex data record
|
||||
string const getYear(InfoMap const & map, string const & key);
|
||||
|
||||
/// return the short form of an authorlist
|
||||
string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
|
||||
|
||||
// return only the family name
|
||||
string const familyName(string const & name);
|
||||
|
||||
/** Search a BibTeX info field for the given key and return the
|
||||
associated field. */
|
||||
string const parseBibTeX(string data, string const & findkey);
|
||||
|
@ -31,50 +31,6 @@ using std::pair;
|
||||
using std::vector;
|
||||
using std::make_pair;
|
||||
|
||||
|
||||
string const getStringFromVector(vector<string> const & vec,
|
||||
string const & delim)
|
||||
{
|
||||
string str;
|
||||
int i = 0;
|
||||
for (vector<string>::const_iterator it = vec.begin();
|
||||
it != vec.end(); ++it) {
|
||||
string item = strip(frontStrip(*it));
|
||||
if (item.empty()) continue;
|
||||
|
||||
if (i++ > 0) str += delim;
|
||||
str += item;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
vector<string> const getVectorFromString(string const & str,
|
||||
string const & delim)
|
||||
{
|
||||
vector<string> vec;
|
||||
if (str.empty())
|
||||
return vec;
|
||||
|
||||
string keys(strip(str));
|
||||
|
||||
for(;;) {
|
||||
string::size_type const idx = keys.find(delim);
|
||||
if (idx == string::npos) {
|
||||
vec.push_back(frontStrip(keys));
|
||||
break;
|
||||
}
|
||||
|
||||
string const key = strip(frontStrip(keys.substr(0, idx)));
|
||||
if (!key.empty())
|
||||
vec.push_back(key);
|
||||
|
||||
string::size_type const start = idx + delim.size();
|
||||
keys = keys.substr(start);
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
string const browseFile(LyXView * lv, string const & filename,
|
||||
string const & title,
|
||||
string const & pattern,
|
||||
|
@ -21,16 +21,6 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/** Functions to convert a string to/from a vector. */
|
||||
|
||||
///
|
||||
string const
|
||||
getStringFromVector(std::vector<string> const & vec, string const & delim=",");
|
||||
|
||||
///
|
||||
std::vector<string> const
|
||||
getVectorFromString(string const & str, string const & delim=",");
|
||||
|
||||
class LyXView;
|
||||
|
||||
/** Launch a file dialog and return the chosen file.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2002-04-14 Herbert Voss <voss@perce.de>
|
||||
|
||||
* FormCharacter.C
|
||||
* FormExternal.C: adding #include "support/lstrings.h"
|
||||
for the getStringFromVector and vice versa
|
||||
|
||||
2002-04-12 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormParagraph.C (changedParagraph): ensure that the warning message
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "combox.h"
|
||||
#include "helper_funcs.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::vector;
|
||||
using std::find;
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "xforms_helpers.h"
|
||||
#include "helper_funcs.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
typedef FormCB<ControlExternal, FormDB<FD_form_external> > base_class;
|
||||
|
||||
FormExternal::FormExternal(ControlExternal & c)
|
||||
|
@ -1,3 +1,9 @@
|
||||
2002-04-14 Herbert Voss <voss@perce.de>
|
||||
|
||||
* lstrings.[Ch]: move the getVectorFromString and the vice versa
|
||||
from frontends/controllers/helper_funcs for better use in other
|
||||
programs
|
||||
|
||||
2002-04-15 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* tempname.C (make_tempfile): simplify the #ifdef block by using
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
using std::count;
|
||||
using std::transform;
|
||||
using std::vector;
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::tolower;
|
||||
@ -632,3 +633,45 @@ string const escape(string const & lab)
|
||||
}
|
||||
return enc;
|
||||
}
|
||||
|
||||
|
||||
/// gives a vector of stringparts which have the delimiter delim
|
||||
vector<string> const getVectorFromString(string const & str,
|
||||
string const & delim)
|
||||
{
|
||||
vector<string> vec;
|
||||
if (str.empty())
|
||||
return vec;
|
||||
string keys(strip(str));
|
||||
for(;;) {
|
||||
string::size_type const idx = keys.find(delim);
|
||||
if (idx == string::npos) {
|
||||
vec.push_back(frontStrip(keys));
|
||||
break;
|
||||
}
|
||||
string const key = strip(frontStrip(keys.substr(0, idx)));
|
||||
if (!key.empty())
|
||||
vec.push_back(key);
|
||||
string::size_type const start = idx + delim.size();
|
||||
keys = keys.substr(start);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
// the same vice versa
|
||||
string const getStringFromVector(vector<string> const & vec,
|
||||
string const & delim)
|
||||
{
|
||||
string str;
|
||||
int i = 0;
|
||||
for (vector<string>::const_iterator it = vec.begin();
|
||||
it != vec.end(); ++it) {
|
||||
string item = strip(frontStrip(*it));
|
||||
if (item.empty()) continue;
|
||||
|
||||
if (i++ > 0) str += delim;
|
||||
str += item;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,13 @@
|
||||
|
||||
//#include <cstring>
|
||||
//#include <cctype>
|
||||
//#include <cctype>
|
||||
#include <vector>
|
||||
|
||||
#include "Lsstream.h"
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
|
||||
///
|
||||
int compare_no_case(string const & s, string const & s2);
|
||||
|
||||
@ -250,4 +251,12 @@ string const rsplit(string const & a, string & piece, char delim);
|
||||
/// Escapes non ASCII chars
|
||||
string const escape(string const & lab);
|
||||
|
||||
/// gives a vector of stringparts which have the delimiter delim
|
||||
std::vector<string> const getVectorFromString(string const & str,
|
||||
string const & delim = ",");
|
||||
|
||||
// the same vice versa
|
||||
string const getStringFromVector(std::vector<string> const & vec,
|
||||
string const & delim = ",");
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user