SlideShare a Scribd company logo
Symbian OS Basics Módulo 3 - Tipos de dados
Tipos de dados elementares Integers Text Boolean Float TAny enums
Integers Symbian OS defines its own basic types: TInt is used for general integer arithmetic: typedef signed int TInt; TUint is used for bitwise flags/handles typedef unsigned int TUint; The following are used where size is of importance: typedef signed char TInt8; typedef unsigned char TUint8; typedef short int TInt16; typedef unsigned short int TUint16; typedef long int TInt32; typedef unsigned long int TUint32;
Text Defaults to 16-bit for Unicode build: TText ch = ‘c’; Build independent wide character: TText16 ch16 = ‘c’; Build independent narrow character: TText8 ch8 = ‘c’;
Boolean Boolean TBool flag = EFalse; // Note the implicit comparison if (!flag) { flag = ETrue; // could also do: flag = !flag; }
Floating Point Definições: typedef float TReal32; typedef double TReal64; typedef double TReal; Exemplo: TReal quotient = 0.234; TReal denominator = 2.431; TReal result = quotient / denominator; Limitação Floating point support is processor dependant, so floats should be avoided for speed reasons.
TAny TAny é definido como void: typedef void TAny TAny is used in preference to void* because it is more suggestive of the actual meaning. e.g. TAny* MyFunction(); TAny usado exclusivamente como um apontador – void is used in preference otherwise e.g. void MyOtherFn();
Enumerations Exemplo de definição: enum TState {EOff, EInit, EOn}; Exemplo de utilização: TState state = GetState(); if (state == EOn) { // Do something }
Conveções de sintaxe Classes ’ T’ classes ’ C’ classes ’ R’ classes ’ M’ classes Variables Functions Casting
T Classes Basic Types: TInt counter = 0; •  Structures: struct TRectArea { TInt iWidth; TInt iHeight; }; •  Classes that do not own external objects/resources and so can be declared on the stack: class TMyPoint { public: TMyPoint(); TMyPoint(TInt aX, TInt aY); TInt iX; TInt iY; };
C Classes If a class needs to allocate memory on the heap it should derive from CBase and begin with a ‘C’: class CExample : public CBase { ... private: CDesCArrayFlat* iArray ; // allocated dynamically ... }; ‘ C’ classes must be declared on the heap: CExample* example = new (ELeave) CExample; ... delete example;
R Classes ‘ R’ classes contain handles to a real resource (other than on the default heap) which is maintained elsewhere Timer example: RTimer timer; // Handle to a timer timer.CreateLocal(); // Tracks the status of request TRequestStatus status; // Request timeout of 5 seconds timer.After(status, 5000000); // Wait for timer to complete synchronously User::WaitForRequest(status); ... timer.Close();
M Classes Características: Abstract Pure virtual functions No member data Propósito: definir um interface Vantagem: reduzir dependências entre classes Regra: the only use of multiple inheritance A C class can derive from one other C class and zero or more M classes Caso de uso: receber notificações de eventos (callback)
M Class Example class CAknAppUi : public CEikAppUi, public MEikStatusPaneObserver, public MCoeViewDeactivationObserver { ... }; class MEikStatusPaneObserver { public: virtual void HandleStatusPaneSizeChange()=0; };
Variáveis Variáveis membro começam com a letra ‘i’ Argumentos começam com ‘a’ Automatics’ (variavéis locais) começam com letra minúscula Constantes começam com a letra ‘K’ Variáveis globais devem ser evitadas, quando necessário, os nomes começam por uma letra maiúscula
Funções Functions’ names indicate what they do Capital letters are used in the beginning of words. e.g. AddFileNameL() Data access functions are named as follows: void SetHeight(TInt aHeight) {iHeight = aHeight;} TInt Height() {return iHeight;} Void GetHeight(TInt& aHeight) {aHeight = iHeight;} Trailing "D" indicates the deletion of an object Trailing "L" means function may leave Trailing "C" means an item is placed on the cleanup stack
Casting Native C++ operators should be used for casting  dynamic_cast Cannot be used as there is no run time type information with Symbian OS static_cast Used to cast a base class to derived class and between base types reinterpret_cast Used to cast a pointer type to another pointer type, to cast an integer type to pointer type and vice versa const_cast Used to remove the const attribute from a type
Assert Catch programming and run-time errors early by using pre- and post-conditions in functions, that is, assert that those conditions required for correct execution hold true. Two mechanisms (macros) support this programming style: __ASSERT_ALWAYS / __ASSERT_DEBUG class invariants.  Both of these mechanisms must be used. They catch programming errors early and aid in communicating the design and purpose of the class.  Avoid macros in release code . Macros are interpreted using text replacement, which is error-prone and never type-safe.  Assertions  __ASSERT_ALWAYS to catch run-time invalid input (avoid usage in released code)  __ASSERT_DEBUG to catch programming errors // Removes text content, commencing at position aPos, over aLength  // number of characters  void CComplexTextObject::Delete(TInt aPos,TInt aLength)  {  __TEST_INVARIANT;  __ASSERT_ALWAYS(aPos>0,Panic(EPosOutsideTextObject));  iTextBuffer->Delete(aPos,aLength);  TEST_INVARIANT;  }

More Related Content

PPT
Exceptions
PPT
7 decision-control
PPTX
Exception handling chapter15
PPTX
Java loops for, while and do...while
PDF
Exception Handling in the C++ Constructor
PPT
Exceptions
PPT
Exception handling
PDF
Java Pitfalls and Good-to-Knows
Exceptions
7 decision-control
Exception handling chapter15
Java loops for, while and do...while
Exception Handling in the C++ Constructor
Exceptions
Exception handling
Java Pitfalls and Good-to-Knows

What's hot (20)

PPTX
Exception handling c++
PDF
PPTX
Exceptions overview
PPTX
Data structures vb
PPT
Java căn bản - Chapter8
PPTX
Exception Handling in C++
PPTX
Exception Handling in object oriented programming using C++
PPTX
Using loops
PPTX
PPTX
Java Decision Control
PPT
M C6java6
PPT
Vb scripting
PDF
14 exception handling
PPT
Exception Handling
PPT
M C6java5
PPTX
Chapter 9.3
PPT
Exception handling and templates
PPTX
Cse lecture-6-c control statement
DOCX
Catch and throw blocks
PPTX
Programming Basics if then else, switch, operators
Exception handling c++
Exceptions overview
Data structures vb
Java căn bản - Chapter8
Exception Handling in C++
Exception Handling in object oriented programming using C++
Using loops
Java Decision Control
M C6java6
Vb scripting
14 exception handling
Exception Handling
M C6java5
Chapter 9.3
Exception handling and templates
Cse lecture-6-c control statement
Catch and throw blocks
Programming Basics if then else, switch, operators
Ad

Viewers also liked (20)

PDF
BK Chapter 5.pdf
PPT
SS 11: Canada's Cold War
PPTX
Estación 4 mi programa de formación
PPT
Presentation_ Tier Overview of I-69 Expansion.ppt
PDF
@Tagtagcity conference_mobile_business
PDF
Inkfish Ontwerp T-Shirts Communicate
PPTX
Egypt podcastchpt12
PPT
Philippines his pla
PDF
CoachingBasics.pdf
PDF
Bukulatihanict la1
PPTX
Bibliotek Pluss – «Bibliotek som vill ha öppet mer»
PPT
PDF
Mikromarc Nyhetsbrev nr. 2/2014
PPT
Europe 1922 maps and quiz
DOCX
Dele god praksis folkebibliotek (Mikromarc Brukermøte 2013)
PPS
Swobodne Spadanie
PPT
Defuse2011
PDF
PPT
Etika & penyalahgunaan
BK Chapter 5.pdf
SS 11: Canada's Cold War
Estación 4 mi programa de formación
Presentation_ Tier Overview of I-69 Expansion.ppt
@Tagtagcity conference_mobile_business
Inkfish Ontwerp T-Shirts Communicate
Egypt podcastchpt12
Philippines his pla
CoachingBasics.pdf
Bukulatihanict la1
Bibliotek Pluss – «Bibliotek som vill ha öppet mer»
Mikromarc Nyhetsbrev nr. 2/2014
Europe 1922 maps and quiz
Dele god praksis folkebibliotek (Mikromarc Brukermøte 2013)
Swobodne Spadanie
Defuse2011
Etika & penyalahgunaan
Ad

Similar to 02 Symbian Os Basics Tipos De Dados (20)

PPTX
Symbian OS - Types And Declarations
TXT
Advance C++notes
PDF
C++ Training
PPTX
Silicon Valley Code Camp - Do you C what I C
PPT
lecture02-cpp.ppt
PPT
lecture02-cpp.ppt
PPT
lecture02-cpp.ppt
PPT
lecture02-cpp.ppt
PPTX
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
PPT
Stroustrup c++0x overview
PPT
c++ ppt.ppt
PPT
lecture5-cpp.pptintroduccionaC++basicoye
PPT
Introduction to Inheritance in C plus plus
PPTX
CS4443 - Modern Programming Language - I Lecture (2)
PPT
C++ - A powerful and system level language
PPTX
C traps and pitfalls for C++ programmers
PPT
UsingCPP_for_Artist.ppt
PPT
Introduction-to-Csharpppppppppppppppp.ppt
Symbian OS - Types And Declarations
Advance C++notes
C++ Training
Silicon Valley Code Camp - Do you C what I C
lecture02-cpp.ppt
lecture02-cpp.ppt
lecture02-cpp.ppt
lecture02-cpp.ppt
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
Stroustrup c++0x overview
c++ ppt.ppt
lecture5-cpp.pptintroduccionaC++basicoye
Introduction to Inheritance in C plus plus
CS4443 - Modern Programming Language - I Lecture (2)
C++ - A powerful and system level language
C traps and pitfalls for C++ programmers
UsingCPP_for_Artist.ppt
Introduction-to-Csharpppppppppppppppp.ppt

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Artificial Intelligence
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
1. Introduction to Computer Programming.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
20250228 LYD VKU AI Blended-Learning.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Artificial Intelligence
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars

02 Symbian Os Basics Tipos De Dados

  • 1. Symbian OS Basics Módulo 3 - Tipos de dados
  • 2. Tipos de dados elementares Integers Text Boolean Float TAny enums
  • 3. Integers Symbian OS defines its own basic types: TInt is used for general integer arithmetic: typedef signed int TInt; TUint is used for bitwise flags/handles typedef unsigned int TUint; The following are used where size is of importance: typedef signed char TInt8; typedef unsigned char TUint8; typedef short int TInt16; typedef unsigned short int TUint16; typedef long int TInt32; typedef unsigned long int TUint32;
  • 4. Text Defaults to 16-bit for Unicode build: TText ch = ‘c’; Build independent wide character: TText16 ch16 = ‘c’; Build independent narrow character: TText8 ch8 = ‘c’;
  • 5. Boolean Boolean TBool flag = EFalse; // Note the implicit comparison if (!flag) { flag = ETrue; // could also do: flag = !flag; }
  • 6. Floating Point Definições: typedef float TReal32; typedef double TReal64; typedef double TReal; Exemplo: TReal quotient = 0.234; TReal denominator = 2.431; TReal result = quotient / denominator; Limitação Floating point support is processor dependant, so floats should be avoided for speed reasons.
  • 7. TAny TAny é definido como void: typedef void TAny TAny is used in preference to void* because it is more suggestive of the actual meaning. e.g. TAny* MyFunction(); TAny usado exclusivamente como um apontador – void is used in preference otherwise e.g. void MyOtherFn();
  • 8. Enumerations Exemplo de definição: enum TState {EOff, EInit, EOn}; Exemplo de utilização: TState state = GetState(); if (state == EOn) { // Do something }
  • 9. Conveções de sintaxe Classes ’ T’ classes ’ C’ classes ’ R’ classes ’ M’ classes Variables Functions Casting
  • 10. T Classes Basic Types: TInt counter = 0; • Structures: struct TRectArea { TInt iWidth; TInt iHeight; }; • Classes that do not own external objects/resources and so can be declared on the stack: class TMyPoint { public: TMyPoint(); TMyPoint(TInt aX, TInt aY); TInt iX; TInt iY; };
  • 11. C Classes If a class needs to allocate memory on the heap it should derive from CBase and begin with a ‘C’: class CExample : public CBase { ... private: CDesCArrayFlat* iArray ; // allocated dynamically ... }; ‘ C’ classes must be declared on the heap: CExample* example = new (ELeave) CExample; ... delete example;
  • 12. R Classes ‘ R’ classes contain handles to a real resource (other than on the default heap) which is maintained elsewhere Timer example: RTimer timer; // Handle to a timer timer.CreateLocal(); // Tracks the status of request TRequestStatus status; // Request timeout of 5 seconds timer.After(status, 5000000); // Wait for timer to complete synchronously User::WaitForRequest(status); ... timer.Close();
  • 13. M Classes Características: Abstract Pure virtual functions No member data Propósito: definir um interface Vantagem: reduzir dependências entre classes Regra: the only use of multiple inheritance A C class can derive from one other C class and zero or more M classes Caso de uso: receber notificações de eventos (callback)
  • 14. M Class Example class CAknAppUi : public CEikAppUi, public MEikStatusPaneObserver, public MCoeViewDeactivationObserver { ... }; class MEikStatusPaneObserver { public: virtual void HandleStatusPaneSizeChange()=0; };
  • 15. Variáveis Variáveis membro começam com a letra ‘i’ Argumentos começam com ‘a’ Automatics’ (variavéis locais) começam com letra minúscula Constantes começam com a letra ‘K’ Variáveis globais devem ser evitadas, quando necessário, os nomes começam por uma letra maiúscula
  • 16. Funções Functions’ names indicate what they do Capital letters are used in the beginning of words. e.g. AddFileNameL() Data access functions are named as follows: void SetHeight(TInt aHeight) {iHeight = aHeight;} TInt Height() {return iHeight;} Void GetHeight(TInt& aHeight) {aHeight = iHeight;} Trailing "D" indicates the deletion of an object Trailing "L" means function may leave Trailing "C" means an item is placed on the cleanup stack
  • 17. Casting Native C++ operators should be used for casting dynamic_cast Cannot be used as there is no run time type information with Symbian OS static_cast Used to cast a base class to derived class and between base types reinterpret_cast Used to cast a pointer type to another pointer type, to cast an integer type to pointer type and vice versa const_cast Used to remove the const attribute from a type
  • 18. Assert Catch programming and run-time errors early by using pre- and post-conditions in functions, that is, assert that those conditions required for correct execution hold true. Two mechanisms (macros) support this programming style: __ASSERT_ALWAYS / __ASSERT_DEBUG class invariants. Both of these mechanisms must be used. They catch programming errors early and aid in communicating the design and purpose of the class. Avoid macros in release code . Macros are interpreted using text replacement, which is error-prone and never type-safe. Assertions __ASSERT_ALWAYS to catch run-time invalid input (avoid usage in released code) __ASSERT_DEBUG to catch programming errors // Removes text content, commencing at position aPos, over aLength // number of characters void CComplexTextObject::Delete(TInt aPos,TInt aLength) { __TEST_INVARIANT; __ASSERT_ALWAYS(aPos>0,Panic(EPosOutsideTextObject)); iTextBuffer->Delete(aPos,aLength); TEST_INVARIANT; }