개발자_이훈규
천천히, 빠르게. 개발자의 Repository
개발자_이훈규
전체 방문자
오늘
어제
  • 분류 전체보기 (473)
    • 티스토리 (4)
    • 개발자 뉴스 (2)
    • 소프트웨어 (203)
      • C (7)
      • c++ (25)
      • Objective-C (3)
      • Do it! 반응형 웹디자인 (4)
      • openGL (8)
      • Java (24)
      • Jni (3)
      • Android (9)
      • Wordpress (2)
      • 버그 만난 후 느낀점 (2)
      • Git (3)
      • node js (2)
      • window tablet (1)
      • HTML (3)
      • javascript (3)
      • perl (1)
      • AngularJS (0)
      • JSON (0)
      • Docker (3)
      • python (5)
      • jQuery (1)
      • MFC (4)
      • cocos studio (6)
      • Golang (1)
      • SQLite3 (0)
      • Spring Boot (8)
      • thymeleaf (0)
      • Django (0)
      • iOS (3)
      • skia (0)
      • VBA (0)
      • PHP (2)
      • Oracle (1)
      • JSP (0)
      • R (0)
    • TCP IP (2)
    • 금융 (0)
      • 금융 Study (0)
      • 금융 Archive (0)
      • 금융 Article (0)
    • 개인 프로젝트 (7)
      • gif 홈페이지 만들기 (0)
      • study app만들기 (0)
      • 크롤러 만들기 (1)
      • 카툰 홈페이지 만들기 (1)
      • 외주 홈페이지 만들기 (3)
      • 웹 홈페이지 만들기 (0)
      • 미디어 서버 만들기 (0)
      • 소개팅 어플 만들기 (0)
      • 인스타그램 풀스택 클론 코딩(인강 노트) (0)
      • 주식 모의거래 만들기 (1)
    • html php mysql (0)
    • node.Js (2)
    • 일상 (2)
    • 빈공간 uml 공부 (0)
    • Ubuntu(linux) (12)
    • 맥OS (10)
      • android 설치하기 (2)
    • Programming quizzes (0)
    • IoT (구 유비쿼터스) (16)
      • 라즈베리 파이 (11)
      • 아두이노 (5)
    • 하드웨어 (5)
      • 아수스 비보탭 노트8 asus vivotap no.. (2)
      • 크레마 카르타 (3)
    • 분석할 문장, 구문, 코드 (0)
    • 키보드 (1)
      • 해피해킹 (1)
    • 코드 라이언 (0)
    • 전자기기 (4)
    • Ted (0)
    • NAS (0)
    • 알고리즘 (0)
    • 연합인포맥스 (0)
    • 이벤트 응모함 (4)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • Java
  • error
  • Python
  • CODE
  • 설치
  • 소스
  • 우분투
  • 개발
  • 코드
  • GIT
  • 에러
  • ubuntu
  • 라즈베리 파이
  • install
  • C
  • 예제
  • 설명
  • C++
  • 방법
  • Example

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
개발자_이훈규

천천히, 빠르게. 개발자의 Repository

카테고리 없음

[class] mgString

2014. 1. 21. 16:17

http://www.sea-of-memes.com/documentation/mgUtil/mgString.html


mgString은 const char*과 비슷하게 보면 되지만 UTF-8 fotmat string으로 가정하게 하는 예약어이다.


Class mgString

Declared in: mgUtil/Util/mgString.h

A variable-length string class. Wherever arguments are "const char*", these are assumed to be UTF-8 format strings. WCHAR arguments should be Unicode string constants, which are handled differently under each platform.

The (const char*) cast returns UTF-8 strings. The toWCHAR method returns a (const wchar_t*), which is only really useful under Windows, where system calls expect a string in this format.

Unfortunately, C++ automatically generates a cast to (const char*) when you code string[i] -- it becomes ((const char*) string)[i]. This allows the caller to iterate through characters, which is not meaningful in a UTF-8 string.

A 'letter' in the class is one or more Unicode characters (a main character and other combining characters) that together form a single symbol in a word. Since the internal format is UTF-8, a single letter may be many bytes.

class mgString

Public Variables

  none.

Public Methods

  mgString()

  mgString(const char* str)

  mgString(const WCHAR* str)

  mgString(const char* str, int len)

  mgString(const WCHAR* str, int len)

  mgString(const mgString& other)

  void setGrowBy(int len)

  void setAllocLength(int len)

  mgString& operator=(char c)

  mgString& operator=(WCHAR c)

  mgString& operator=(const char* str)

  mgString& operator=(const WCHAR* str)

  mgString& operator=(const mgString& other)

  mgString& operator+=(char c)

  mgString& operator+=(WCHAR c)

  mgString& operator+=(const char* str)

  mgString& operator+=(const WCHAR* str)

  mgString& operator+=(const mgString& buffer)

  mgString& write(const char* data, int len)

  mgString& write(const WCHAR* data, int len)

  int nextLetter(int posn, char* letter = NULL)

  int prevLetter(int posn, char* letter = NULL)

  int countLetters()

  void empty()

  int length()

  BOOL isEmpty()

  operator const char*()

  void toWCHAR(WCHAR*& target, int& len)

  int compareN(int len, const char* str)

  int compareN(int len, const WCHAR* str)

  BOOL equals(const char* str)

  BOOL equals(const WCHAR* str)

  BOOL equalsIgnoreCase(const char* str)

  BOOL equalsIgnoreCase(const WCHAR* str)

  int find(int posn, char c)

  int find(int posn, WCHAR c)

  int find(int posn, const char* str, int len = -1)

  int find(int posn, const WCHAR* str, int len = -1)

  int reverseFind(int posn, char c)

  int reverseFind(int posn, WCHAR c)

  int reverseFind(int posn, const char* str, int len = -1)

  int reverseFind(int posn, const WCHAR* str, int len = -1)

  BOOL startsWith(const char* string)

  BOOL startsWith(const WCHAR* string)

  BOOL endsWith(const char* string)

  BOOL endsWith(const WCHAR* string)

  void trimLeft()

  void trimRight()

  void trim()

  BOOL isSpace(int posn)

  BOOL isDigit(int posn)

  BOOL isHexDigit(int posn)

  BOOL isAlphaNumeric(int posn)

  void makeLower()

  void deleteAt(int posn, int len)

  void insertAt(int posn, const char* str, int len = -1)

  int setLetter(int posn, const char* letter, int len = -1)

  int setLetter(int posn, const int* chars, int len)

  void deleteLettersAt(int posn, int len)

  void substring(mgString& target, int posn, int len)

  void substring(mgString& target, int posn)

  int getToken(int posn, const char* delims, mgString& token)

  int scan(const char* fmt, ...)

  int scan(const WCHAR* fmt, ...)

  void format(const char* fmt, ...)

  void format(const WCHAR* fmt, ...)

  void formatV(const char* fmt, va_list args)

  void formatV(const WCHAR* fmt, va_list args)

  int fromUTF8(const char* source, int& utfCount)

  int lenWCHAR(const char* source, int len)

  void toWCHAR(const char* source, WCHAR*& target, int& len)

Protected Variables

  int m_allocLen

  int m_dataLen

  int m_growBy

  char* m_data

  char m_shortData[ MG_SHORT_STRING_LEN]

Protected Methods

  void init()

  void grow(int newLen)

  int lenUTF8(int c)

  int lenUTF8(const WCHAR* source, int len)

  void toUTF8(char* target, int& len, int source)

Details


public
mgString()

constructor


public
mgString(
  const char* str);

constructor


public
mgString(
  const WCHAR* str);

constructor


public
mgString(
  const char* str,
  int len);

constructor


public
mgString(
  const WCHAR* str,
  int len);

constructor


public
mgString(
  const mgString& other);

constructor


public
void setGrowBy(
  int len);

allocation increased by growby when string full


public
void setAllocLength(
  int len);

set memory allocated for string


public
mgString& operator=(
  char c);

assign to a character


public
mgString& operator=(
  WCHAR c);

assign to a character


public
mgString& operator=(
  const char* str);

assign to a string


public
mgString& operator=(
  const WCHAR* str);

assign to a string


public
mgString& operator=(
  const mgString& other);

assign to a string


public
mgString& operator+=(
  char c);

append char to string


public
mgString& operator+=(
  WCHAR c);

append char to string


public
mgString& operator+=(
  const char* str);

append to string


public
mgString& operator+=(
  const WCHAR* str);

append to string


public
mgString& operator+=(
  const mgString& buffer);

append to string


public
mgString& write(
  const char* data,// data to append
  int len);// length of data

append to string


public
mgString& write(
  const WCHAR* data,// data to append
  int len);// length of data

append to string


public const
int nextLetter(
  int posn,
  char* letter = NULL);

return next letter in a string. This may be more than a single Unicode character, if combining characters were supported.


public const
int prevLetter(
  int posn,
  char* letter = NULL);

return previous letter in a string. This may be more than a single Unicode character, if combining characters were supported.


public const
int countLetters()

return number of 'letters' in a string. Multiple unicode characters can make up a letter.


public
void empty()

reset the buffer to length 0


public const
int length()

return the length


public const
BOOL isEmpty()

return true if empty


public const
operator const char*()

return buffer as const UTF-8 string


public const
void toWCHAR(
  WCHAR*& target,
  int& len);

return Unicode string. caller owns storage


public const
int compareN(
  int len,// length to compare
  const char* str);// comparison string

compare N letters of a string


public const
int compareN(
  int len,// length to compare
  const WCHAR* str);// comparison string

compare N letters of a string


public const
BOOL equals(
  const char* str);// comparison string

compare to a string


public const
BOOL equals(
  const WCHAR* str);// comparison string

compare to a string


public const
BOOL equalsIgnoreCase(
  const char* str);// comparison string

compare ignore case


public const
BOOL equalsIgnoreCase(
  const WCHAR* str);// comparison string

compare ignore case


public const
int find(
  int posn,// starting letter position
  char c);// char to find

find character


public const
int find(
  int posn,// starting letter position
  WCHAR c);// char to find

find character


public const
int find(
  int posn,// starting letter position
  const char* str,// string to find
  int len = -1);// length of string (bytes)

find substring


public const
int find(
  int posn,// starting letter position
  const WCHAR* str,// string to find
  int len = -1);// length of string (unicode chars)

find substring


public const
int reverseFind(
  int posn,// ending letter position
  char c);// char to find

find last occurance of char


public const
int reverseFind(
  int posn,// ending letter position
  WCHAR c);// char to find

find last occurance of char


public const
int reverseFind(
  int posn,// ending letter position
  const char* str,// string to find
  int len = -1);// length (bytes)

find last occurance of substring


public const
int reverseFind(
  int posn,// ending letter position
  const WCHAR* str,// string to find
  int len = -1);// length (unicode chars)

find last occurance of substring


public const
BOOL startsWith(
  const char* string);

return true if starts with string


public const
BOOL startsWith(
  const WCHAR* string);

return true if starts with string


public const
BOOL endsWith(
  const char* string);

return true if ends with string


public const
BOOL endsWith(
  const WCHAR* string);

return true if ends with string


public
void trimLeft()

remove leading white space


public
void trimRight()

remove trailing white space


public
void trim()

remove leading and trailing white space


public const
BOOL isSpace(
  int posn);

return true if char posn is a space


public const
BOOL isDigit(
  int posn);

return true if char posn is a digit


public const
BOOL isHexDigit(
  int posn);

return true if char posn is a hex digit


public const
BOOL isAlphaNumeric(
  int posn);

return true if char posn is alpha numeric


public
void makeLower()

convert to lower case


public
void deleteAt(
  int posn,// starting letter offset
  int len);// count of letters

delete text


public
void insertAt(
  int posn,// letter offset
  const char* str,// string to insert
  int len = -1);// length of string

insert into string


public
int setLetter(
  int posn,// letter offset
  const char* letter,// letter codes
  int len = -1);// length of string

replace a letter, return next position


public
int setLetter(
  int posn,// letter offset
  const int* chars,// unicode characters
  int len);// count of characters

replace a letter, return next position


public
void deleteLettersAt(
  int posn,// starting letter offset
  int len);// count of letters

delete letters


public const
void substring(
  mgString& target,
  int posn,// letter offset
  int len);// length (bytes)

extract substring


public const
void substring(
  mgString& target,
  int posn);

extract from position to end of string


public const
int getToken(
  int posn,
  const char* delims,
  mgString& token);

get next token, return ending position


public const
int scan(
  const char* fmt,
  ...);

scan string and extract items


public const
int scan(
  const WCHAR* fmt,
  ...);

scan string and extract items


public
void format(
  const char* fmt,
  ...);

format string to buffer


public
void format(
  const WCHAR* fmt,
  ...);

format wide string to buffer


public
void formatV(
  const char* fmt,
  va_list args);

format string to buffer, variable args


public
void formatV(
  const WCHAR* fmt,
  va_list args);

format wide string to buffer, variable args


public static
int fromUTF8(
  const char* source,
  int& utfCount);

convert UTF8 string to unicode


public static
int lenWCHAR(
  const char* source,
  int len);

return length of string in WCHAR


public static
void toWCHAR(
  const char* source,
  WCHAR*& target,
  int& len);

return Unicode string. caller owns storage


protected
int m_allocLen;

allocation length


protected
int m_dataLen;

data length


protected
int m_growBy;

size of increase in alloc


protected
char* m_data;

data to add


protected
char m_shortData[ MG_SHORT_STRING_LEN];

initial data


protected
void init()

shared initialization


protected
void grow(
  int newLen);// length needed

grow buffer to hold new length


protected static
int lenUTF8(
  int c);

return length of UTF-8 encoded char


protected static
int lenUTF8(
  const WCHAR* source,
  int len);

return length of UTF-8 encoded string


protected static
void toUTF8(
  char* target,
  int& len,
  int source);

convert to UTF8 format


저작자표시 비영리 (새창열림)
    개발자_이훈규
    개발자_이훈규
    혼자 꽁양꽁양 개발하면서 놀아요~ - 노트같은 블로그

    티스토리툴바