mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-18 00:54:19 +00:00
Changes for VC6 compatibility; added a couple of trimming methods to String; added a parameter to Socket::createConnection
This commit is contained in:
parent
d3ff5d9c4b
commit
93e4236b57
13 changed files with 142 additions and 29 deletions
|
|
@ -7753,7 +7753,7 @@ void StreamingSocket::close()
|
|||
isListener = false;
|
||||
}
|
||||
|
||||
bool StreamingSocket::createListener (const int newPortNumber)
|
||||
bool StreamingSocket::createListener (const int newPortNumber, const String& localHostName)
|
||||
{
|
||||
if (connected)
|
||||
close();
|
||||
|
|
@ -7766,6 +7766,10 @@ bool StreamingSocket::createListener (const int newPortNumber)
|
|||
zerostruct (servTmpAddr);
|
||||
servTmpAddr.sin_family = PF_INET;
|
||||
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
|
||||
if (localHostName.isNotEmpty())
|
||||
servTmpAddr.sin_addr.s_addr = ::inet_addr (localHostName.toUTF8());
|
||||
|
||||
servTmpAddr.sin_port = htons ((uint16) portNumber);
|
||||
|
||||
handle = (int) socket (AF_INET, SOCK_STREAM, 0);
|
||||
|
|
@ -12133,6 +12137,39 @@ const String String::trimEnd() const throw()
|
|||
return String (text->text, (int) (++endT - text->text));
|
||||
}
|
||||
|
||||
const String String::trimCharactersAtStart (const tchar* charactersToTrim) const throw()
|
||||
{
|
||||
jassert (charactersToTrim != 0);
|
||||
|
||||
if (isEmpty())
|
||||
return empty;
|
||||
|
||||
const tchar* t = text->text;
|
||||
|
||||
while (CharacterFunctions::indexOfCharFast (charactersToTrim, *t) >= 0)
|
||||
++t;
|
||||
|
||||
if (t == text->text)
|
||||
return *this;
|
||||
else
|
||||
return String (t);
|
||||
}
|
||||
|
||||
const String String::trimCharactersAtEnd (const tchar* charactersToTrim) const throw()
|
||||
{
|
||||
jassert (charactersToTrim != 0);
|
||||
|
||||
if (isEmpty())
|
||||
return empty;
|
||||
|
||||
const tchar* endT = text->text + (CharacterFunctions::length (text->text) - 1);
|
||||
|
||||
while ((endT >= text->text) && CharacterFunctions::indexOfCharFast (charactersToTrim, *endT) >= 0)
|
||||
--endT;
|
||||
|
||||
return String (text->text, (int) (++endT - text->text));
|
||||
}
|
||||
|
||||
const String String::retainCharacters (const tchar* const charactersToRetain) const throw()
|
||||
{
|
||||
jassert (charactersToRetain != 0);
|
||||
|
|
@ -44035,8 +44072,8 @@ void CodeDocument::insert (const String& text, const int insertPos, const bool u
|
|||
lastAffectedLine = lines.size();
|
||||
}
|
||||
|
||||
int lineStart = newFirstLine->lineStartInFile;
|
||||
for (int i = firstAffectedLine; i < lines.size(); ++i)
|
||||
int i, lineStart = newFirstLine->lineStartInFile;
|
||||
for (i = firstAffectedLine; i < lines.size(); ++i)
|
||||
{
|
||||
CodeDocumentLine* const l = lines.getUnchecked (i);
|
||||
l->lineStartInFile = lineStart;
|
||||
|
|
@ -44044,7 +44081,7 @@ void CodeDocument::insert (const String& text, const int insertPos, const bool u
|
|||
}
|
||||
|
||||
const int newTextLength = text.length();
|
||||
for (int i = 0; i < positionsToMaintain.size(); ++i)
|
||||
for (i = 0; i < positionsToMaintain.size(); ++i)
|
||||
{
|
||||
CodeDocument::Position* const p = positionsToMaintain.getUnchecked(i);
|
||||
|
||||
|
|
@ -44135,7 +44172,8 @@ void CodeDocument::remove (const int startPos, const int endPos, const bool undo
|
|||
lines.removeRange (firstAffectedLine + 1, numLinesToRemove);
|
||||
}
|
||||
|
||||
for (int i = firstAffectedLine + 1; i < lines.size(); ++i)
|
||||
int i;
|
||||
for (i = firstAffectedLine + 1; i < lines.size(); ++i)
|
||||
{
|
||||
CodeDocumentLine* const l = lines.getUnchecked (i);
|
||||
const CodeDocumentLine* const previousLine = lines.getUnchecked (i - 1);
|
||||
|
|
@ -44144,7 +44182,7 @@ void CodeDocument::remove (const int startPos, const int endPos, const bool undo
|
|||
|
||||
const int totalChars = getNumCharacters();
|
||||
|
||||
for (int i = 0; i < positionsToMaintain.size(); ++i)
|
||||
for (i = 0; i < positionsToMaintain.size(); ++i)
|
||||
{
|
||||
CodeDocument::Position* p = positionsToMaintain.getUnchecked(i);
|
||||
|
||||
|
|
@ -90215,7 +90253,7 @@ Image* Path::createMaskBitmap (const AffineTransform& transform,
|
|||
Image* im = Image::createNativeImage (Image::SingleChannel, imagePosition.getWidth(), imagePosition.getHeight(), true);
|
||||
|
||||
EdgeTable edgeTable (Rectangle (0, 0, imagePosition.getWidth(), imagePosition.getHeight()),
|
||||
*this, transform.translated (-imagePosition.getX(), -imagePosition.getY()));
|
||||
*this, transform.translated ((float) -imagePosition.getX(), (float) -imagePosition.getY()));
|
||||
|
||||
int stride, pixelStride;
|
||||
uint8* const pixels = (uint8*) im->lockPixelDataReadWrite (0, 0, imagePosition.getWidth(), imagePosition.getHeight(), stride, pixelStride);
|
||||
|
|
@ -242079,7 +242117,7 @@ bool QuickTimeMovieComponent::loadMovie (const File& movieFile_,
|
|||
bool QuickTimeMovieComponent::loadMovie (const URL& movieURL,
|
||||
const bool isControllerVisible)
|
||||
{
|
||||
return loadMovie ((InputStream*) movieURL_.createInputStream (false), isControllerVisible);
|
||||
return loadMovie ((InputStream*) movieURL.createInputStream (false), isControllerVisible);
|
||||
}
|
||||
|
||||
void QuickTimeMovieComponent::goToStart()
|
||||
|
|
|
|||
|
|
@ -1994,6 +1994,22 @@ public:
|
|||
/** Returns a copy of this string with any whitespace characters removed from the end. */
|
||||
const String trimEnd() const throw();
|
||||
|
||||
/** Returns a copy of this string, having removed a specified set of characters from its start.
|
||||
Characters are removed from the start of the string until it finds one that is not in the
|
||||
specified set, and then it stops.
|
||||
@param charactersToTrim the set of characters to remove. This must not be null.
|
||||
@see trim, trimStart, trimCharactersAtEnd
|
||||
*/
|
||||
const String trimCharactersAtStart (const tchar* charactersToTrim) const throw();
|
||||
|
||||
/** Returns a copy of this string, having removed a specified set of characters from its end.
|
||||
Characters are removed from the end of the string until it finds one that is not in the
|
||||
specified set, and then it stops.
|
||||
@param charactersToTrim the set of characters to remove. This must not be null.
|
||||
@see trim, trimEnd, trimCharactersAtStart
|
||||
*/
|
||||
const String trimCharactersAtEnd (const tchar* charactersToTrim) const throw();
|
||||
|
||||
/** Returns an upper-case version of this string. */
|
||||
const String toUpperCase() const throw();
|
||||
|
||||
|
|
@ -13063,11 +13079,14 @@ public:
|
|||
which will spawn new sockets for each new connection, so that these can
|
||||
be handled in parallel by other threads.
|
||||
|
||||
This returns true if it manages to open the socket successfully.
|
||||
@param portNumber the port number to listen on
|
||||
@param localHostName the interface address to listen on - pass an empty
|
||||
string to listen on all addresses
|
||||
@returns true if it manages to open the socket successfully.
|
||||
|
||||
@see waitForNextConnection
|
||||
*/
|
||||
bool createListener (const int portNumber);
|
||||
bool createListener (const int portNumber, const String& localHostName = String::empty);
|
||||
|
||||
/** When in "listener" mode, this waits for a connection and spawns it as a new
|
||||
socket.
|
||||
|
|
@ -44635,8 +44654,8 @@ public:
|
|||
|
||||
/** Called by a CodeDocument when it is altered.
|
||||
*/
|
||||
virtual void codeDocumentChanged (const CodeDocument::Position& affectedTextStart,
|
||||
const CodeDocument::Position& affectedTextEnd) = 0;
|
||||
virtual void codeDocumentChanged (const Position& affectedTextStart,
|
||||
const Position& affectedTextEnd) = 0;
|
||||
};
|
||||
|
||||
/** Registers a listener object to receive callbacks when the document changes.
|
||||
|
|
@ -44703,7 +44722,8 @@ public:
|
|||
private:
|
||||
friend class CodeDocumentInsertAction;
|
||||
friend class CodeDocumentDeleteAction;
|
||||
friend class CodeDocument::Iterator;
|
||||
friend class Iterator;
|
||||
friend class Position;
|
||||
|
||||
OwnedArray <CodeDocumentLine> lines;
|
||||
Array <Position*> positionsToMaintain;
|
||||
|
|
|
|||
|
|
@ -778,8 +778,8 @@ void CodeDocument::insert (const String& text, const int insertPos, const bool u
|
|||
lastAffectedLine = lines.size();
|
||||
}
|
||||
|
||||
int lineStart = newFirstLine->lineStartInFile;
|
||||
for (int i = firstAffectedLine; i < lines.size(); ++i)
|
||||
int i, lineStart = newFirstLine->lineStartInFile;
|
||||
for (i = firstAffectedLine; i < lines.size(); ++i)
|
||||
{
|
||||
CodeDocumentLine* const l = lines.getUnchecked (i);
|
||||
l->lineStartInFile = lineStart;
|
||||
|
|
@ -787,7 +787,7 @@ void CodeDocument::insert (const String& text, const int insertPos, const bool u
|
|||
}
|
||||
|
||||
const int newTextLength = text.length();
|
||||
for (int i = 0; i < positionsToMaintain.size(); ++i)
|
||||
for (i = 0; i < positionsToMaintain.size(); ++i)
|
||||
{
|
||||
CodeDocument::Position* const p = positionsToMaintain.getUnchecked(i);
|
||||
|
||||
|
|
@ -879,7 +879,8 @@ void CodeDocument::remove (const int startPos, const int endPos, const bool undo
|
|||
lines.removeRange (firstAffectedLine + 1, numLinesToRemove);
|
||||
}
|
||||
|
||||
for (int i = firstAffectedLine + 1; i < lines.size(); ++i)
|
||||
int i;
|
||||
for (i = firstAffectedLine + 1; i < lines.size(); ++i)
|
||||
{
|
||||
CodeDocumentLine* const l = lines.getUnchecked (i);
|
||||
const CodeDocumentLine* const previousLine = lines.getUnchecked (i - 1);
|
||||
|
|
@ -888,7 +889,7 @@ void CodeDocument::remove (const int startPos, const int endPos, const bool undo
|
|||
|
||||
const int totalChars = getNumCharacters();
|
||||
|
||||
for (int i = 0; i < positionsToMaintain.size(); ++i)
|
||||
for (i = 0; i < positionsToMaintain.size(); ++i)
|
||||
{
|
||||
CodeDocument::Position* p = positionsToMaintain.getUnchecked(i);
|
||||
|
||||
|
|
|
|||
|
|
@ -302,8 +302,8 @@ public:
|
|||
|
||||
/** Called by a CodeDocument when it is altered.
|
||||
*/
|
||||
virtual void codeDocumentChanged (const CodeDocument::Position& affectedTextStart,
|
||||
const CodeDocument::Position& affectedTextEnd) = 0;
|
||||
virtual void codeDocumentChanged (const Position& affectedTextStart,
|
||||
const Position& affectedTextEnd) = 0;
|
||||
};
|
||||
|
||||
/** Registers a listener object to receive callbacks when the document changes.
|
||||
|
|
@ -372,7 +372,8 @@ public:
|
|||
private:
|
||||
friend class CodeDocumentInsertAction;
|
||||
friend class CodeDocumentDeleteAction;
|
||||
friend class CodeDocument::Iterator;
|
||||
friend class Iterator;
|
||||
friend class Position;
|
||||
|
||||
OwnedArray <CodeDocumentLine> lines;
|
||||
Array <Position*> positionsToMaintain;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_Graphics.h"
|
||||
#include "../fonts/juce_GlyphArrangement.h"
|
||||
#include "../geometry/juce_PathStrokeType.h"
|
||||
#include "juce_EdgeTable.h"
|
||||
#include "juce_LowLevelGraphicsContext.h"
|
||||
#include "../brushes/juce_GradientBrush.h"
|
||||
#include "../brushes/juce_ImageBrush.h"
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
#include "../geometry/juce_Path.h"
|
||||
#include "../geometry/juce_RectangleList.h"
|
||||
#include "../colour/juce_ColourGradient.h"
|
||||
#include "juce_EdgeTable.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#include "juce_LowLevelGraphicsPostScriptRenderer.h"
|
||||
#include "juce_EdgeTable.h"
|
||||
#include "../imaging/juce_Image.h"
|
||||
#include "../colour/juce_PixelFormats.h"
|
||||
#include "../geometry/juce_PathStrokeType.h"
|
||||
|
|
|
|||
|
|
@ -1604,7 +1604,7 @@ Image* Path::createMaskBitmap (const AffineTransform& transform,
|
|||
Image* im = Image::createNativeImage (Image::SingleChannel, imagePosition.getWidth(), imagePosition.getHeight(), true);
|
||||
|
||||
EdgeTable edgeTable (Rectangle (0, 0, imagePosition.getWidth(), imagePosition.getHeight()),
|
||||
*this, transform.translated (-imagePosition.getX(), -imagePosition.getY()));
|
||||
*this, transform.translated ((float) -imagePosition.getX(), (float) -imagePosition.getY()));
|
||||
|
||||
int stride, pixelStride;
|
||||
uint8* const pixels = (uint8*) im->lockPixelDataReadWrite (0, 0, imagePosition.getWidth(), imagePosition.getHeight(), stride, pixelStride);
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ void StreamingSocket::close()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
bool StreamingSocket::createListener (const int newPortNumber)
|
||||
bool StreamingSocket::createListener (const int newPortNumber, const String& localHostName)
|
||||
{
|
||||
if (connected)
|
||||
close();
|
||||
|
|
@ -442,6 +442,10 @@ bool StreamingSocket::createListener (const int newPortNumber)
|
|||
zerostruct (servTmpAddr);
|
||||
servTmpAddr.sin_family = PF_INET;
|
||||
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
|
||||
if (localHostName.isNotEmpty())
|
||||
servTmpAddr.sin_addr.s_addr = ::inet_addr (localHostName.toUTF8());
|
||||
|
||||
servTmpAddr.sin_port = htons ((uint16) portNumber);
|
||||
|
||||
handle = (int) socket (AF_INET, SOCK_STREAM, 0);
|
||||
|
|
|
|||
|
|
@ -135,11 +135,14 @@ public:
|
|||
which will spawn new sockets for each new connection, so that these can
|
||||
be handled in parallel by other threads.
|
||||
|
||||
This returns true if it manages to open the socket successfully.
|
||||
@param portNumber the port number to listen on
|
||||
@param localHostName the interface address to listen on - pass an empty
|
||||
string to listen on all addresses
|
||||
@returns true if it manages to open the socket successfully.
|
||||
|
||||
@see waitForNextConnection
|
||||
*/
|
||||
bool createListener (const int portNumber);
|
||||
bool createListener (const int portNumber, const String& localHostName = String::empty);
|
||||
|
||||
/** When in "listener" mode, this waits for a connection and spawns it as a new
|
||||
socket.
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ bool QuickTimeMovieComponent::loadMovie (const File& movieFile_,
|
|||
bool QuickTimeMovieComponent::loadMovie (const URL& movieURL,
|
||||
const bool isControllerVisible)
|
||||
{
|
||||
return loadMovie ((InputStream*) movieURL_.createInputStream (false), isControllerVisible);
|
||||
return loadMovie ((InputStream*) movieURL.createInputStream (false), isControllerVisible);
|
||||
}
|
||||
|
||||
void QuickTimeMovieComponent::goToStart()
|
||||
|
|
|
|||
|
|
@ -1748,6 +1748,39 @@ const String String::trimEnd() const throw()
|
|||
return String (text->text, (int) (++endT - text->text));
|
||||
}
|
||||
|
||||
const String String::trimCharactersAtStart (const tchar* charactersToTrim) const throw()
|
||||
{
|
||||
jassert (charactersToTrim != 0);
|
||||
|
||||
if (isEmpty())
|
||||
return empty;
|
||||
|
||||
const tchar* t = text->text;
|
||||
|
||||
while (CharacterFunctions::indexOfCharFast (charactersToTrim, *t) >= 0)
|
||||
++t;
|
||||
|
||||
if (t == text->text)
|
||||
return *this;
|
||||
else
|
||||
return String (t);
|
||||
}
|
||||
|
||||
const String String::trimCharactersAtEnd (const tchar* charactersToTrim) const throw()
|
||||
{
|
||||
jassert (charactersToTrim != 0);
|
||||
|
||||
if (isEmpty())
|
||||
return empty;
|
||||
|
||||
const tchar* endT = text->text + (CharacterFunctions::length (text->text) - 1);
|
||||
|
||||
while ((endT >= text->text) && CharacterFunctions::indexOfCharFast (charactersToTrim, *endT) >= 0)
|
||||
--endT;
|
||||
|
||||
return String (text->text, (int) (++endT - text->text));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const String String::retainCharacters (const tchar* const charactersToRetain) const throw()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -613,6 +613,22 @@ public:
|
|||
/** Returns a copy of this string with any whitespace characters removed from the end. */
|
||||
const String trimEnd() const throw();
|
||||
|
||||
/** Returns a copy of this string, having removed a specified set of characters from its start.
|
||||
Characters are removed from the start of the string until it finds one that is not in the
|
||||
specified set, and then it stops.
|
||||
@param charactersToTrim the set of characters to remove. This must not be null.
|
||||
@see trim, trimStart, trimCharactersAtEnd
|
||||
*/
|
||||
const String trimCharactersAtStart (const tchar* charactersToTrim) const throw();
|
||||
|
||||
/** Returns a copy of this string, having removed a specified set of characters from its end.
|
||||
Characters are removed from the end of the string until it finds one that is not in the
|
||||
specified set, and then it stops.
|
||||
@param charactersToTrim the set of characters to remove. This must not be null.
|
||||
@see trim, trimEnd, trimCharactersAtStart
|
||||
*/
|
||||
const String trimCharactersAtEnd (const tchar* charactersToTrim) const throw();
|
||||
|
||||
//==============================================================================
|
||||
/** Returns an upper-case version of this string. */
|
||||
const String toUpperCase() const throw();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue